(This was originally in an other senction but many told me to ask here, hopefully someone can answer this) I am having a major problem in my new browser app.
Okay so I made game where different cubes (squares) spawn at the top of the screen and I use the Tween class to make them go down the screen and then disappear.
However I want to detect a collision when a cube hits the player (that is also a flying cube).
I tried everything, truly everything but it does not seem to work. The problematic thing is that when I remove the "Tween" function it does detect collision with the hitTestObject method but when I add the "Tween" line collision won't be detected anymore.
The code looks like this:
function enemiesTimer (e:TimerEvent):void {
newEnemy = new Enemy1();
layer2.addChild(newEnemy);
newEnemy.x = Math.random() * 700;
newEnemy.y = 10;
if (enemiesThere == 0)
{
enemiesThere = true;
player.addEventListener(Event.ENTER_FRAME, collisionDetection)
}
var Tween1:Tween = new Tween(newEnemy, "y", null, newEnemy.y, newEnemy.y+distance, movingTime, true); }
The collision detection part:
private function collisionDetection (e:Event):void
{
if (player.hitTestObject(newEnemy))
{
trace("aaa");
}
}
*Another weird thing is that the collision detection works only in the starting point, where the squares spawn but they aren't really there anymore so I don't quite get it.
I hope someone can answer this and maybe tell me how I can code this. Thanks in advance :)
*I've tried out Tweener & TweenMax as well, the problem is always the same
hitTestPoint
though again, it will depend on what the built-in function is actually doing. \$\endgroup\$