Jump to content

Adding rotation to a curve follower and destroying it after it finishes its path


Recommended Posts

I am attempting to 'animate' the throwing of a tetromino sprite. The animation is simply the tetromino following a Curve while rotating. Once the 'animation' is done (after the tetromino reaches the end of the Curve) I would like to destroy the tetromino.


However, looking at the API documentation for PathFollower, it is not clear to me how to detect when the sprite reaches the end of the Curve. I see a lot of event-related methods, but those seem to be for defining your own custom events rather than detecting set events like doneFollowing or something.


For the rotation, I would like to set a callback to rotate the sprite at every point along the curve, but that doesn't seem possible either. Am I missing something in the API doc, or is a Curve/PathFollower approach not ideal for this scenario to begin with?


Here is my code so far:

const points = [
    variableX, variableY,   
    END_X, END_Y

export default function ThrowAnimator(args) {

    let {gameObjectFactory, duration} = args;
    let curve = new Phaser.Curves.Spline(points);

    this.animateThrow = function(tetrominoShape) {


        let follower = gameObjectFactory.follower(curve, START_X, START_Y, tetrominoShape + 'Whole');

        follower.setRotateToPath(true, 90);

            duration: duration,
            yoyo: false,
            ease: 'Sine.easeInOut',
            repeat: 0



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...