Here for example I want that if that “x” entity collide with the “Enemy” entity my “player” entity does (hInput -= 1)
Here is what i have so far:
if (collide(“Enemy”, x, y)) { (hInput -= 1); }
THX whoever helps me out:)
Here for example I want that if that “x” entity collide with the “Enemy” entity my “player” entity does (hInput -= 1)
Here is what i have so far:
if (collide(“Enemy”, x, y)) { (hInput -= 1); }
THX whoever helps me out:)
Assuming you want to call a function on the enemy you collide with, this should do the trick:
var e:Enemy = Enemy(collide("Enemy", x, y));
if (e != null)
{
// e is the enemy you collided with
}
No, actually what I wanted is that if that entity “x” collide with the “Enemy” entity it would call a function on the “player” entity.
Sry if I was not very clear
So…are you not running this code in your player entity? This is the kind of info you should be putting in the main body of the thread.
You can set make the Player instance available anywhere in your game with the name property.
public function Player()
{
name = "player";
}
And retrieve it with world.getInstance().
var p:Player = Player(world.getInstance("player"));
if (p != null)
{
// p is a valid instance of the Player class.
}