Doug

Animation pivot points

Recommended Posts

Hi all

I've got an animation of a running ninja (original hey).  Sprite sheets attached.

I am doing the following in my code:

Preload function:

this.load.atlas('sprites', this.p('Sprites.png'), this.p('Sprites.json'));

Create function:

        this.ninja = this.physics.add.sprite(this.gameWidth/2, this.gameHeight/2, 'sprites', 'stand').setCollideWorldBounds(true);

        let runConfig = {
            key: 'run', 
            frames: this.anims.generateFrameNames('sprites', { 
                prefix: 'run', 
                start: 1, 
                end: 7, 
                zeroPad: 0 
            }), 
            repeat: -1,
            frameRate: 5
        }
        this.anims.create(runConfig);

        this.ninja.play('run');

I am using texturepacker (https://www.codeandweb.com/texturepacker) to create the sprite sheet as a Phaser3 spritesheet.

I have set the pivot points for each frame to be on the ninja's chin so that the head is always still when he is running.

When I run the game the character jolts left and right as if it is ignoring the pivot points that I've set in texture packer.

Is this a bug or am I missing something obvious please?

Thanks so much!

Sprites.json

Sprites.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.