View Full Version : Animate walking character to respond to controls
Zephyris
January 3rd, 2008, 04:30 PM
Well I've decided to do a simpler thing then an RPG, a simple little platformer. I drew a little dude, then I animated him walking. But now I just need to figure out how to make him stand there and blink or something when the user isn't pressing any keys, and then when left or right his pressed, it starts the walking animation and he moves. Is this too hard and can someone tell me what I need to do to do this?
I admit I'm only good at the timeline part of Flash, the programming is difficult for me.
skimmmer
January 3rd, 2008, 05:56 PM
First you need to know how to detect when a Key is pressed (you can put this code in the actions for the movieclip):
if(Key.isDown(Key.RIGHT)){
//functions
}
Note: If you use a key like "W" or any other letter you must use a ASCII code in place of the Key.RIGHT (for the example above)
Then put functions in:
if(Key.isDown(Key.RIGHT)){
this.gotoAndStop(certain frame); //this goes to the frame in the movieclip and stops
}
Repeat this for other Keys and then put this for when the character isn't doing anything:
if(!Key.isDown(Key.RIGHT) && same for other keys){
this.gotoAndStop(certain frame); //this goes to the frame in the movieclip where he does nothing
}
Note: "!" in the code means "not" so if the key is NOT down (something happens). && is "and", so if all of the keys that make him move are not "down" then it will go to a certain frame in the movieclip.
Good Luck
Zephyris
January 3rd, 2008, 07:49 PM
Here's the problem though... I made the character's animation by making seperate parts of his body different graphic symbols. Is there a way I can make all of this a movieclip so I can put actions to it?
What I've tried doing is going to the frames before the animation and then taking all of his body parts, breaking them down, and then making all the parts a movieclip just for that frame. But then I got in there with the actions, played around with it, and got nothing. At first it gave me some syntax error so I deleted the notes in it, then put a 2 where the frame thing said. It gave me no errors but when I tested it, nothing happened.
Sorry, I'm a newbie. -_-
skimmmer
January 3rd, 2008, 08:22 PM
Just select all the graphics and right click then select "convert to symbol" and select movieclip.
Then under the properties panel click the blue arrow to the right and put in the script. Remember that you have to specify the frame number in "gotoAndStop(frame#);".
Zephyris
January 3rd, 2008, 08:49 PM
Just select all the graphics and right click then select "convert to symbol" and select movieclip.
Then under the properties panel click the blue arrow to the right and put in the script. Remember that you have to specify the frame number in "gotoAndStop(frame#);".
I've tried doing that but it fails to work, it messes up the animation (such as his body begins veering off to the right or his head is detached)
I must have the wrong version of Flash. I don't see any blue arrows.
Is there a way for me to send what I have to you so you can figure it out? I know this is lazy but I feel like my version (Flash MX Education Edition) is missing something crucial.
This is the link to the flash file, if it helps: http://www.btcomics.com/Flash/Chibi%20Kingdom/KaikuroCharacterWalk.fla
skimmmer
January 3rd, 2008, 09:32 PM
Here is the file that works, sorry it was a white arrow (without actionscript). I made a few new movieclips and just pasted the frames into them and put the code into the first one. Look at the code inside to get a better understanding.
Zephyris
January 3rd, 2008, 09:47 PM
Wow! I wasn't thinking youd fix it for me! I'll be reading those codes right away and learning more about actionscipting so I won't have to bug you again.
Thank you so much! ^_^
I'll try to see if I can get him to face the direction he stopped in... but that might be too hard, wouldn't it?
I also should've done his standing still animation as well, would this make too much to the process?
Again I thank you for your help.
You may also want to know where I'm going with this. Basically, its like a little mystery adventure game. You run into things to trigger something. Run into a character to talk to them, run through a doorway to go somwhere, etc. There won't be any inventory, its just a mystery, problem solving thing.
skimmmer
January 3rd, 2008, 10:34 PM
You might want to look in the flash part of kirupa, there are some pretty good flash/actionscript tutorials there. Good luck!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.