Hello! I have a problem with colliding. I have two Entities.:
-
Player is moving in update():
override public function update():void { super.update(); if (!world.bPlayingCutscene) { if (Input.check(Key.RIGHT)) { moveBy(speed * FP.elapsed, 0, Game.COLLISIONS); } else if (Input.check(Key.LEFT)) { moveBy(-speed * FP.elapsed, 0, Game.COLLISIONS); }
if (Input.check(Key.DOWN)) { moveBy(0, speed * FP.elapsed, Game.COLLISIONS); } if (Input.check(Key.UP)) { moveBy(0, -speed * FP.elapsed, Game.COLLISIONS); } layer = -(y + Game.PLAYER_HEIGHT); } FP.camera.x = -FP.halfWidth / FP.screen.scale + x; FP.camera.x = FP.clamp(FP.camera.x, 0, Game.WIDTH - FP.screen.width / FP.screen.scale); FP.camera.y = -FP.halfHeight / FP.screen.scale + y; FP.camera.y = FP.clamp(FP.camera.y, -100, Game.HEIGHT - FP.screen.height / FP.screen.scale); }
and the second Entity is “pseudo enemy” for now who is following us in update():
override public function update():void
{
if (!world.bPlayingCutscene)
{
if (x < world.player.x)
{
moveBy(speed * FP.elapsed, 0, Game.COLLISIONS);
}
if (x > world.player.x)
{
moveBy(-speed * FP.elapsed, 0, Game.COLLISIONS);
}
if (y < world.player.y)
{
moveBy(0, speed * FP.elapsed, Game.COLLISIONS);
}
if (y > world.player.y)
{
moveBy(0, -speed * FP.elapsed, Game.COLLISIONS);
}
if (collide("player", x, y))
{
world.recycle(this);
}
super.update();
}
layer = -(y + gfxHeight);
}
But the If statement isn’t true…
And the Game.COLLISIONS:
public static const COLLISIONS:Array = ["map", "player", "nurser"];
Someone have an idea how to solve?