The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:42 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 5 posts ] 
[Request] Movement using Arrow Keys 
Author Message
User avatar

Joined: Tue Dec 23, 2008 10:22 am
Posts: 4
Location: nowhere
Ihave tried to make a very simple flash game before (moving an object with the arrow keys) and i failed miserably, due to one annyoying error. "Else does not meet if" or something like that. Could somebody please help me resolve this issue and maybe even help me build on my flash game?

P.S. I'm new to these forums, as you can see by my post count.

_________________
"Windows does not detect a keyboard. Please press ENTER to continue."


Tue Dec 23, 2008 11:02 am
User avatar

Joined: Mon Aug 11, 2008 1:09 pm
Posts: 166
Location: England lol
Gender: Male
Currently Playing: Minecraft
carrottop wrote:
Ihave tried to make a very simple flash game before (moving an object with the arrow keys) and i failed miserably, due to one annyoying error. "Else does not meet if" or something like that. Could somebody please help me resolve this issue and maybe even help me build on my flash game?

P.S. I'm new to these forums, as you can see by my post count.


Well by the error given I would assume there's a problem with your If statement - an Else can only accompany a preceding If. The following code should solve your problem and make your object move using the Arrow keys :)

Code:
onClipEvent(load) {
  //Set speed of movement
  speed = 10;
}
onClipEvent(enterFrame) {
  //Movement Horizontally
  if(Key.isDown(Key.RIGHT)) {
    _x += speed;
  } else if(Key.isDown(Key.LEFT)) {
    _x -= speed;
  }

  //Movement Vertically
  if(Key.isDown(Key.DOWN)) {
    _y += speed;
  } else if(Key.isDown(Key.UP)) {
    _y -= speed;
  }
}


Tue Dec 23, 2008 9:46 pm
WWW
User avatar

Joined: Tue Dec 23, 2008 10:22 am
Posts: 4
Location: nowhere
thanks. Maybe now i build on my "game"

_________________
"Windows does not detect a keyboard. Please press ENTER to continue."


Fri Dec 26, 2008 10:13 pm
User avatar

Joined: Fri Aug 22, 2008 10:24 pm
Posts: 68
Location: do you have to know?
Gender: Male
what did you use? flash or game maker

_________________
Image ImageImage


Thu Jan 01, 2009 6:31 pm
WWW
User avatar

Joined: Tue Dec 23, 2008 10:22 am
Posts: 4
Location: nowhere
I use flash mx 2004

_________________
"Windows does not detect a keyboard. Please press ENTER to continue."


Thu Jan 15, 2009 1:49 pm
Display posts from previous:  Sort by  
 [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.