Hi, I am new to flashpunk and am having trouble getting my entity to move across the screen. I’ve followed a few different tutorials and replicated their code, but it does not seem to move. These are my classes:
package { import net.flashpunk.Engine; import net.flashpunk.FP; import net.flashpunk.World;
public class Main extends Engine
{
private var gameWorld:MyWorld;
public function Main()
{
super(800, 600, 60, false);
gameWorld = new MyWorld;
}
override public function init():void
{
FP.world = gameWorld;
trace("FlashPunk has started successfully!");
}
}
}
package { import net.flashpunk.World;
public class MyWorld extends World
{
private var gameEntity:MyEntity;
public function MyWorld()
{
gameEntity = new MyEntity();
add(gameEntity);
}
override public function update():void
{
//trace("MyEntity updates");
}
}
}
package
{
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.utils.Key;
import net.flashpunk.utils.Input;
import net.flashpunk.FP;
public class MyEntity extends Entity
{
[Embed(source = "dragon.png")] private const IMAGE:Class;
public function MyEntity()
{
graphic = new Image(IMAGE);
setHitbox(50, 50);
width = 50;
height = 50;
}
override public function update():void
{
x += 100;
y += 50;
if (Input.check(Key.LEFT)) { x -= 5; }
if (Input.check(Key.RIGHT)) { x += 5; }
if (Input.check(Key.UP)) { y -= 5; }
if (Input.check(Key.DOWN)) { y += 5; }
}
override public function added():void
{
trace("Entity added");
}
}
}
Any help?