View Full Version : [AS3] How do i make a character move and turn using arrow keys?
12-19-2010, 11:09 PM
I'm really terrible with actionscript and no matter where i look i just cant seem to find a tutorial for as3 in which it explains how to make an animated character move and turn using the arrow keys. Would appreciate any help i can get or even a link to a tutorial if anyone has found a good one. Thanks!
12-19-2010, 11:47 PM
Very simple setup here. I made a object and made it a symbol and converted to symbol(named it Ball). Then exported it for ActionScript.
I then made a actionscript file and named it Main.as and insterted the following under.
public class Main extends Sprite
private var ball:Ball;
private var speed:Number = 5;
public function Main ():void
ball = new Ball();
ball.x = stage.stageWidth/2;
ball.y = stage.stageHeight/2;
private function KeyDown (key:KeyboardEvent):void
ball.x -= speed;
ball.x += speed;
ball.y -= speed;
ball.y += speed;
Bare in mind that this is NOT the best way to do it. It is just a simple way to get you started.
If you want to have more smooth flow in the movement and add some physic, check out Foundation Actionscript 3.0 Animation: Making Things Move! great book to start with.
Good luck with your scripting!
12-20-2010, 12:00 AM
thanks so much! this is an awesome starting point for me to work from ^_^
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.