Nazariglez / pixi-tween

pixi-tween is a plugin for Pixi.js v3.0.8 or higher to create tween animations.
MIT License
98 stars 39 forks source link

TweenPath #12

Open developer-av opened 6 years ago

developer-av commented 6 years ago

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

liran commented 5 years ago

The same question.

liran commented 5 years ago

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

Ewan-Roberts commented 5 years ago

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()