-
Key.isDown to be used in a button
Hi! Please help! T_T
What i want is to use buttons to move my character.. In my flash game i made a button, when clicked it will make my
character move.. i don't need to use keyboard movements..
This is my codings actionscript 3.0:
import flash.events.Event;
hero.gotoAndStop('still');
var Key:KeyObject = new KeyObject(stage);
stage.addEventListener(Event.ENTER_FRAME,onenter)
function onenter(e:Event):void{
if(Key.isDown(Key.RIGHT)){
hero.x+=5;
hero.scaleX=-1;
hero.gotoAndStop('walking');
}
else if(Key.isDown(Key.LEFT)){
hero.x-=5;
hero.scaleX=1;
hero.gotoAndStop('walking');
}
else hero.gotoAndStop('still');
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|