I’m trying to make it so that once the test screen is opened my enemy pic will move across the stage and wrap back to the beginning until the screen is closed. Any help would be appreciated as I don’t even know where to begin.
Current code:
import flash.events.Event;
var bg:background = new background
addChild (bg);
var pp: PlayerPic = new PlayerPic
addChild (pp);
pp.x= 125
pp.y= 550
pp.height = 40
pp.width = 50
var ep:EnemyPic = new EnemyPic
addChild (ep);
ep.x= 55
ep.y= 50
ep.height= 40
ep.width= 50
stage.addEventListener(KeyboardEvent.KEY_DOWN, arrowMove)
function arrowMove(event:KeyboardEvent):
void
{
if (event.keyCode == Keyboard.LEFT)
{
pp.x -= 5;
if (pp.x < 0)
{
pp.x = 0;
}
}
if (event.keyCode == Keyboard.RIGHT)
{
pp.x += 5;
if (pp.x > 250)
{
pp.x = 250;
}
}
if (event.keyCode == Keyboard.UP)
{
pp.y -= 5;
if (pp.y < 0)
{
pp.y = 0;
}
}
if (event.keyCode == Keyboard.DOWN)
{
pp.y += 5;
if (pp.y > 550)
{
pp.y = 550;
}
}
}