Here's the thing : I have a ball bouncing using Tweens, and I want to detect collisions between the ball and platforms (only when the ball is falling down).
But, my solution is testing for collisions in an ENTER_FRAME
loop, so when the ball speed is to high, at a x frame the ball is above the plateform, and at a x+1 frame the ball is below the platform, so my loop never detects collision (because the ball and the platform never really collide).
Here's the jump method of my ball :
public function jump():void
{
TweenLite.killTweensOf(this);
TweenLite.to(this, jumpSpeed, {y:250, ease:Cubic.easeOut});
TweenLite.to(this, jumpSpeed, {delay:jumpSpeed, y:stage.stageHeight-this.height, ease:Cubic.easeIn, onComplete:jump});
}
And here's what's executed in my ENTER_FRAME
loop :
for each (var platform:Platform in platforms)
{
if (ball.hitTestObject(platform) && ballPreviousY < ball.y)
ball.jump();
}
ballPreviousY = ball.y;
I already started to work on a solution using the physics engine Box2D, but I would like to know if there was a simpler solution to that problem.