I have a game entity which loads up the character/map etc the usual game things. In this it makes a call to my entity called “Map” which generates my Ogmo map. This works fine, it adds everything it should, in this function I loop through the entities found in the map and one of them is called “House”.
I set the hitbox of the house using setHitbox(80, 56);
and I set the type to house using type = "house";
and I have also set the hitbox and type in player by using the following:
type = "player";
setHitbox(14, 24);
in my player entity file I have the following check function
public function checkCollide(Position:Point):Boolean {
if (collide("house", Position.x, Position.y)) {
trace("true collide");
return true;
} else {
//trace("False collide");
return false;
}
}
and for the player controls I have the following
if (Input.check("run_up")) {
if (!checkCollide(new Point(player.x, player.y))) {
player.play("runUp");
player.y -= speed;
}
}
the problem is, checkcollide never returns true. I run over the house like a god! The way I tested to check if the values were setting correct was simply added moveBy(player.x, player.y, "house");
and this collides, it shows that the type is set correctly but why does my checkCollide always return false?
The problem with moveBy is that it doesn’t allow multiple types so it doesn’t seem very practical!