Sign in to follow this  

[web] Ship doesn't move

This topic is 2543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there all, just making my first endeavours into flash programming. I'm following this tutorial:

http://asgamer.com/2009/as3-flash-games-for-beginners-character-movement-handling-multiple-keypresses

At the moment my background and player ship display perfectly and there are no compiler errors, however the ship doesn't move at all. I'm not sure where I'm going wrong because I've followed the tutorial perfectly.

Here is a sample of my Engine and PlayerShip code:

Engine:


package com.spacerace
{

import flash.display.MovieClip;
import flash.display.Stage;

public class Engine extends MovieClip
{
public function Engine()
{
var spaceBackdrop : Space = new Space();
var playerShip : PlayerShip = new PlayerShip();

stage.addChild(spaceBackdrop);

spaceBackdrop.x = stage.width / 2;
spaceBackdrop.y = stage.height / 2;

stage.addChild(playerShip);

playerShip.x = 60;
playerShip.y = 100;
}
}
}


PlayerShip:

package com.spacerace
{
import flash.display.MovieClip;
import flash.display.Stage;
import com.senocular.utils.KeyObject;
import flash.ui.Keyboard;
import flash.events.Event;

public class Ship extends MovieClip {

private var stageRef:Stage;
private var key:KeyObject;

public function PlayerShip(stageRef:Stage)
{
this.stageRef = stageRef;
key = new KeyObject(stageRef);

addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}

public function loop(e:Event) : void
{
y--;
}
}
}


PlayerShip is linked to the PlayerShip class. Base class is MovieClip.

Any help would be much appreciated!

Share this post


Link to post
Share on other sites

This topic is 2543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this