1. 2015 is going to be a great year for Android! Why wait??
    Samsung Galaxy Note 5 | Samsung Galaxy S6 | HTC One M9
  2. New Forum Created: Samsung Gear VR!

if(Key.isDown) to be used in a button


  1. juliuz0001

    juliuz0001 Member

    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');
    }

    Advertisement
    :
Loading...

Share This Page