updateHitbox not working after scaling with FlxTween
-
Hello, here is my function when a power up collides with my Pong paddle:
public function paddlePowerUp(powerUP:PowerUp, paddle:Paddle) { kill(); FlxTween.tween(paddle, {"scale.y": 2}, 0.3, {}); //paddle.setGraphicSize(Std.int(paddle.width), Std.int(paddle.height) * 2); paddle.updateHitbox(); }
If I do setGraphic without the tween the hitbox will expand, but not with the FlxTween. Any thoughts?
-
You want to
updateHitbox()
after the tween completes.
-
@dean said in updateHitbox not working after scaling with FlxTween:
{ onComplete: paddle.updateHitbox });
Thanks, unfortunately I get this error:
source/PowerUp.hx:54: characters 52-85 : Void -> Void should be Null<flixel.tweens.TweenCallback>
source/PowerUp.hx:54: characters 52-85 : Void -> Void should be flixel.tweens.TweenCallback
source/PowerUp.hx:54: characters 52-85 : Void -> Void should be flixel.tweens.FlxTween -> Void
source/PowerUp.hx:54: characters 52-85 : For optional function argument 'Options'Still having trouble understanding "Void."
-
Adding the solution in case someone needs this in the future:
FlxTween.tween(paddle, { "scale.y": 2 }, 0.3, { onComplete: tweenComplete.bind(_, paddle) }); private function tweenComplete(tween:FlxTween, paddle:Paddle):Void { paddle.updateHitbox(); }