Okay I was making this funny little Mario type game and I got stuck. Here’s my problem… When I push the right arrow I’ve got the guy moving to the right but it looks as though he’s sliding across ice and not moving his feet, so I was wondering how i could get him to perform his little running move…“foot up foot down”, while I was holding the right key in. Can anyone explain to me… or maybe there’s a tutorial that I haven’t looked at?
Frame 1 = normal standing position character and a stop() action on the frame.
Frame 2 = One leg forward character
Frame 3 = Other left forward character with a gotoAndPlay(2) action on the frame
That is what inside the character clip would look like.
Now… go back to the stage that contains your character movie clip and right click on your character and open the actions panel.
Then in the onClipEvent(enterFrame) you will add the actions for the key press. Now I am not entirely sure how you did this, but im assuming you use if Key.isDown() to check, so I will just say… if Key.isDown(Key.RIGHT) then play the character clip, this will loop the animation of the running else if the right key isn’t pressed, gotoAndStop(1) to set it back in the standing position.
Why is that Sen? Frame 3 would be hit and displayed, and it would gotoAndPlay frame 2 which will be hit, displayed, then moved back to frame 3, which will loop back to frame 2.
when the gotoAndPlay(2) statement is read, its read and executed before updating the frame. The frame only updates after all code has finished executing and the final results of the screen are shown. After that the frame prgresses and the process repeats. In reading that gotoAndPlay(2), though, that frame is never really seen because Flash moved to frame 2 before the screen refresh. Really, any frame with a gotoAndPlay statement is never seen. Wanna crash Flash? put a gotoAndPlay(2) on frame 1 and a gotoAndPlay(1) on frame 2. infinite loop =)
Frame looping is commonly done with actions on frame 1 and a gotoAndPlay(1) on frame 2. That way the frame 1 is repeated everyframe (this was especially the case in Flash 4 before enterFrame events). When Flash reaches frame 2 on that second frame, it reads gotoAndPlay(1), goes to frame 1 then reads that code, repeating the process every frame.
So if you want to cycle through 2 frames in a movieclip, frames 2 and 3, then the gotoAndPlay for frame 2 should be in frame 4 since if it was in 3, 3 would never be seen…
Okay, I’ve got another problem that doesn’t really have to do with the character but I didn’t really want to make another thread. I tried to add some jump physics in there but he just falls through the tile he’s supposed to stand on (in which I couldnt move through without the gravity) and I have no idea what I should do.