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


  • Recently Browsing   0 members

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