I'm making a simple game. The character is movable with the arrow keys. The enemies are moving around the screen with a (classic) tween.
I want to detect collision between the character and the enemies. At first I thought it was working properly, but it also seems to detect a collision on the starting position from the enemies. So even if the enemies are already moving/tweening away from their start position, there's a collision detected between the character and these starting positions. (please ask questions if you don't quite get what I mean)
First method:
addEventListener(Event.ENTER_FRAME, checkIfHitTest);
function checkIfHitTest(Event)
{
if(player.hitTestObject(enemies))
{
trace("yes");
}
else
{
trace("no");
}
}
This didn't work properly because it seems to detect the collition even if the enemy moved away from the starting point. (Probably because the ENTER_FRAME but correct me if i'm wrong)
My question to you: What's causing the detection and what is the best way to detect collision between a tweening movieclip and a movieclip wich is movable with the arrowkeys?
