Skip to main content
Participant
April 20, 2013
Question

How to make a first-person style game with arrow key movement?

  • April 20, 2013
  • 2 replies
  • 747 views

Hey guys, I've made some simple click-to-move 1st person games with AS3, but I just wanted to know if there was a way to move around in 1st person with arrow keys, I was thinking you could get the background to move with the arrow keys, but that would be a little confusing.

If you guys have any suggestions for me, or if it's possible, please reply! Thanks

This topic has been closed for replies.

2 replies

Inspiring
April 20, 2013

You need a virtual camera to achieve what you intend if you are not using stage3D.

Ned Murphy
Legend
April 20, 2013

Here is a basic switch usage to move something with the keyboard:

stage.addEventListener(KeyboardEvent.KEY_DOWN, move_mc);

function move_mc(event:KeyboardEvent):void {
    switch(event.keyCode)
    {
       case  Keyboard.LEFT : mc.x -= 5
       break;
 
       case  Keyboard.RIGHT : mc.x += 5
       break;
 
       case Keyboard.UP : mc.y -= 5
       break;
 
       case Keyboard.DOWN : mc.y += 5
       break;
    }
}

Slim_AceAuthor
Participant
April 20, 2013

Well... I already knew how to do that, and it doesn't really answer my question, but thanks anyway.

WitchXHunter
Inspiring
April 20, 2013

you just have to change the mouse control to keyboard control like what Ned said. just imagine the mc is your background then you just make it move the opposite way of your key press, and limit the movement around the border.