First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: monkey boy

HTML Document Structure

Player animation

the first thing you need to do is create a movie clip. Inside the movie clip draw your player1. Remember to draw every part in different layers. Once you have done that insert another layer and call it actions. in this layer you need to place an invisable button. then in the actions for frame 1 of the actions layer enter this code stop();

Player animation(cont)

Now create a key frame in frame 2 of every layer. using motion tweens create your players first attack e.g kick,punch,whatever. At the final frame of the actions layer enter this code gotoAndStop(1); Do this for three other attacks, with the same code at the end. If you want you can do two more animations one for croching and another for jumping.

Player controls

at the moment if you placed this movie clip on the main timeline and tested the movie nothing would happen. well it's time to change that. to do this create a button and insert a keyframe on the frame called hit. in this keyframe draw whatever the hell you want because no one will se it. once you have done that place it in the actions layer of your player movieclip. and enter this code on (keyPress "") { gotoAndPlay("Jump"); } on (keyPress "") { gotoAndPlay("Crouch"); } on (keyPress "6") { gotoAndPlay("Right kick"); } on (keyPress "2") { gotoAndPlay("Left kick"); } on (keyPress "4") { gotoAndPlay("Left punch"); } note: you may have to change this code a bit to get it to work depending on the length of each attack. You may have also noticed that there isn't any code for a Right punch. now all that needs to be done is movement.

Player movement

the last part and easiest to do all you need to do is place an instance of the player movie clip on the main timeline and enter this code onClipEvent (load) { moveSpeed = 5; } onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { _x -= moveSpeed; } if (Key.isDown(Key.RIGHT)) { _x += moveSpeed; } } And thats it. If you want you can add a second player by duplicationg the origional movie clip flip the whole thing horrizontaly and change the buttons. the next tutorial will cover hitTest and damage metres

» Level Intermediate

Added: 2005-01-20
Rating: 4 Votes: 15
» Author
Some brit
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.