Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus 6 | Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old 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
Exclamation 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');
}

Advertisements
juliuz0001 is offline  
Last edited by juliuz0001; January 9th, 2013 at 09:04 AM.
Reply With Quote
sponsored links
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.