Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

TweenPath #12

Open
developer-av opened this issue Mar 14, 2018 · 3 comments
Open

TweenPath #12

developer-av opened this issue Mar 14, 2018 · 3 comments

Comments

@developer-av
Copy link

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

@liran
Copy link

liran commented Feb 22, 2019

The same question.

@liran
Copy link

liran commented Feb 22, 2019

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

@Ewan-Roberts
Copy link
Contributor

Ewan-Roberts commented Sep 16, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants