My character in my game has to jump out the way just in time, so i made the animation for it and decided to use run animation.
It looked great to tell the truth, but when i set my characters view back to the original walking view, he jumped back to where he started.
So i tried setting his view to the jumping out the way view, and just made him walk to the spot i wanted him to jump to. Good idea in theory
When i did that, he repeated the same action over and over until he got to the spot i wanted him to be(like he would when he's walking), so thats no good either
How do i do run animation and make my character be where i want them to be afterwards?
You could try changeing the character's x and y coords just before/after you chnage the view back - that should move them immediately (I think temporarily changing the walkspeed to 0 and using Character.Walk would do it, too).
However - does your 'jump out of the way' animation contain the movement (the char stays at the same (x,y) and just looks like they're moving? If so, maybe you could take the movment out of the anim and into the script - ending the char at the right place when you reset the view.
I'm probably doing this the hard way :P
My character stands in one place, and it just looks like he's jumping to another spot.
How would i take the movement out of the anim and put it into the script?
You'd have to crop each frame so that the center of the sprite was always centered on the character - and then you'd have to send a move command as the animation runs. I think it's probably simpler just to keep the animation you have, and use x,y coordinates directly. Perhaps hiding the character (the On property, cCharacter.On = false; ) would help prevent it from showing up in the wrong place for that instant when you change the view and move him.
Quotecrop each frame so that the center of the sprite was always centered on the character - and then you'd have to send a move command
Yes, that's what I meant.
However, thinking about it, a better way might be to hide the player character (
cEgo.Tranparency = 100 for example) and turn on an object/other character to run the animation as it is now (movement in anim), then reposition the invisible character turn the object/other char off and the first character back on.
That (if you followed it) would save the effort of cropping the sprites, and of working out the movement for the character.
All you need to do is keep your current code and add a couple of lines to it as was suggested above and illustrated below.
#define NORMAL_PLAYER 1
#define JUMPING_PLAYER 2
player.ChangeView(JUMPING_PLAYER);
player.Animate(0, 0, eOnce, eBlocking);
Wait(10); // or however long it takes to finish animation
player.StopMoving();
player.x = xx; // xx = new x position
player.y = yy; // yy = new y position
player.ChangeView(NORMAL_PLAYER);
Thanks guys. I used a bit of help from everyone ;D
character[EGO].Transparency = 100;
made an object run like the character animation would have.
player.x = xx; // xx = new x position
player.y = yy; // yy = new y position
reset my characters transparency, and it worked like a charm