I am making a platform game using flash and I am having a little trouble, so I would like to know how to make a running character by pressing an arrow key down. I鈥檝e already set up the characters key frame in flash in an animation to run, what I am trying to do is make it run when an arrow key is press down and stops running when a arrow key isn鈥檛 being pressed, actionscript is tricky.How to make a Flash game using Actionscript?
There is a MC with 4 frame inside.
1st frame: front (frame name: front) (MC name: MCfront)
2nd frame: back (frame name: back) (MC name: MCback)
3rd frame: left (frame name: left) (MC name: MCleft)
4th frame: right (frame name: right) (MC name: MCright)
Each of these frames has another MC that has 2 more frames inside.
1st frame: still image
2nd frame: walking animation
Remember to put ';stop();'; on all of these frames.
The following AS is to be put on the first MC:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x += 4.5;
this.gotoAndStop(';right';);
this.MCright.gotoAndStop(2);
}else{
this.MCright.gotoAndStop(1);
}
if(Key.isDown(Key.LEFT)){
this._x -= 4.5;
this.gotoAndStop(';left';);
this.MCleft.gotoAndStop(2);
}else{
this. MCleft.gotoAndStop(1);
}
if(Key.isDown(Key.UP)){
this._y -= 4.5;
this.gotoAndStop(';back';);
this.MCback.gotoAndStop(2);
}else{
this. MCback.gotoAndStop(1);
}
if(Key.isDown(Key.DOWN)){
this._y += 4.5;
this.gotoAndStop(';front';);
this.MCfront.gotoAndStop(2);
}else{
this. MCfront.gotoAndStop(1);
}
}
If you need any help or a source file IM on Yahoo! and feel free to ask. =DHow to make a Flash game using Actionscript?
wedding planner y=x^2-9 is a quite simple equation. You are quite an edaquate person, my love. You will go far in life. I am a super sonically speedy awesomeness changing altering falling machineynessness fortuneteller! The answer is quite simple to the equation that is awesomelynessositynessly awesomenessly awesome that is y=x^2-9!!! The answer is all in your in BRAIN!!!!!!!!!!!!!!
y=x^2-9 is a quite simple equation. You are quite an edaquate person, my love. You will go far in life. I am a super sonically speedy awesomeness changing altering falling machineynessness fortuneteller! The answer is quite simple to the equation that is awesomelynessositynessly awesomenessly awesome that is y=x^2-9!!! The answer is all in your in bra...I mean BRAIN!!!!!!!!!!!!!!
I found a tutorial that may work for you.
Best of luck.
http://www.flash.0tutor.com/archive/111/Flash-dodge-ball-game-part-2-character-key-moving.shtml
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment