hi everyone. i’m new to this board, but i’ve been working nonstop on a sidescroller platform game for a while now and i have a problem that i just can’t seem to fix. normally if i get stuck on something i’ll search the web and message boards to find an answer, but in this case i had no luck. the forums at newgrounds.com tend to have a lot of useful information, but lately asking for help there is like asking for a kick in the face. they’re too mean.
now, about my problem. in my game, you use the right and left direction keys to move your character right and left, and space bar to jump. the trouble lies in the actual walking animation. i have four frames inside my character’s movie clip. 1 is walking right, 2 is standing still (facing right), 3 is walking left, and 4 is standing still (facing left).
the part of my script pertaining to the issue looks like this:
if(key.isDown(key.RIGHT)and disable == false)
{
_root.moving=“right”
_root.background._x-=5
this.gotoAndPlay(1);
}
if(key.isDown(key.LEFT)and disable == false)
{
_root.moving=“left”
_root.background._x+=5
this.gotoAndStop(3);
}
else
if (_root.moving==“left”)
{
gotoAndStop(4);
}
this script tells the clip to walk right when the right key is pressed, walk left when the left key is pressed, and face in the direction which corresponds to the last direction in which the player was walking once the keys are no longer being pressed. on a quick sidenote, facing right when stopped after walking right does not work the way it should. i can see that frame 2 of the movie clip (which is the character standing still and facing right) is not mentioned, and i’m just not sure how to add it in.
the real problem is that even though the movie clip follows the commands and goes to the correct frames of the clip when told, it does not play the animation contained in that frame. for instance, frame 1 of the character’s main movie clip contains a movie clip of him walking right, but when the main clip goes to that frame, it only shows the first frame of the clip therein. i have come to understand that the reason for this is when you hold the right key down, it is sending rapid consecutive commands to go to this frame, therefore always being at the start of the clip and never being able to follow through with the animation. i need for it to play through and repeat the walking animation as the key is held down.
i am hoping that someone here will be able to help me modify my current code to accomodate these corrections. i am very proud of my game so far, especially the rest of the character’s code (including his gravity and jump scripts which work particularly well) and for that reason i’m quite hesitant about any drastic changes to other parts of the code (meaning parts other than that which pertains to walking left and right).
thanks in advance, i appreciate any help you can give.