pixi-tween icon indicating copy to clipboard operation
pixi-tween copied to clipboard

TweenPath

Open developer-av opened this issue 7 years ago • 3 comments

Hi, how can I find out the current animation point?

developer-av avatar Mar 14 '18 10:03 developer-av

The same question.

liran avatar Feb 22 '19 05:02 liran

I need to adjust the direction of the car as it moves.

liran avatar Feb 22 '19 06:02 liran

I tend to use _tmpPoint

If you log the result of a path you will find it attached to the TweenPath object. For example:

   const tween = PIXI.tweenManager.createTween(sprite);
   tween.path = new PIXI.tween.TweenPath();
   tween.path.moveTo(10, 200).lineTo(200, 200); // draw your path

   tween.on('update', () => {
     const current_point = tween.path._tmpPoint;
     const rotation_to_point = Math.atan2(sprite.y - current_point.y, current_point.x - sprite.x);
     sprite.rotation = rotation_to_point
   });
   tween.start()

Ewan-Roberts avatar Sep 16 '19 06:09 Ewan-Roberts