January 9th, 2013, 08:59 AM
|
#1 (permalink)
|
|
New Member
Thread Author (OP)
Join Date: May 2012
Posts: 10
Device(s):
Carrier: Not Provided
Thanks: 0
Thanked 0 Times in 0 Posts
|
if(Key.isDown) to be used in a button
Hi guys! Please help me T_T
I am making a android game that has a left and right movement.. I made two buttons for the left and right movements.
What i want is to make my character move when I press the left/right button, i don't need to use keyboard movements..
So how can i make my character move using the left/right button.
These are my codes actionscript 3.0:
import flash.events.Event;
hero.gotoAndStop('still');
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');
}
|
|
|
Last edited by juliuz0001; January 9th, 2013 at 09:04 AM.
|
|