Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-22-2012, 02:20 AM   #1
drjuanitor
Registered User
 
Join Date: Apr 2012
Posts: 2
Default [AS3] how to code each arrow key to correspond to each symbol to make the character m

so im currently taking a game development class in my high school and im trying to make a character go up, down, left, and right. i have made a symbol for each direction. im working with action script 3 and i dont know how to code each arrow key to correspond to each symbol to make the character move in that direction. it would be awesome if some one could give a step by step example so i can learn a little more by it! thanks
ps: if you need more information than what i gave, let me know.
drjuanitor is offline   Reply With Quote
Old 04-23-2012, 05:30 PM   #2
TJRobertson86
Registered User
 
Join Date: Apr 2012
Posts: 37
Default

You dont need to create a symbol for each direction (unless i misunderstand your question), you'll probably want to create a variable for each direction, however. The easiest way to do it (assuming you have a newer version of flash professional) is to use the code snipet for move with keyboard. It will write all the code for you, and then you can read through it and look up anything you dont understand.
TJRobertson86 is offline   Reply With Quote
Old 04-24-2012, 07:28 AM   #3
Poony
Senior Member
 
Poony's Avatar
 
Join Date: Aug 2011
Location: Sweden
Posts: 387
Default

This is basicly the bare minimum for making a display object move when a key is pressed. In this case your character's instance name is "character"

Hope this points you in the right direction.

ActionScript Code:
const speed:int = 2; stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown); function handleKeyDown(e:KeyboardEvent):void {         if(e.keyCode == Keyboard.LEFT) character.x -= speed;     if(e.keyCode == Keyboard.RIGHT) character.x += speed;     if(e.keyCode == Keyboard.UP) character.y -= speed;     if(e.keyCode == Keyboard.DOWN) character.y += speed; }
Poony is offline   Reply With Quote
Old 04-30-2012, 07:26 PM   #4
drjuanitor
Registered User
 
Join Date: Apr 2012
Posts: 2
Default

so i dont have to make a symbol for each of the directions the character is facing?
drjuanitor is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT. The time now is 09:39 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.