Jump to content

How can I change setSize with tweens


AlexArroyoDuque
 Share

Recommended Posts

Hi. 

I have a sprite with chained tweens.

 

The first twenn move the x position of the sprite. And the second tween change the scale to -1.2. I do this because the sprite must turn.

 

My problem is that the size doesn't follow correctly the sprite.

 

This is my code.

 

            this.mummy = this.game.add.sprite(580, 406, 'mummy');

            this.mummy.scale.setTo(-1.2, 1.2);

            this.mummy.body.gravity.y = 8;

 

            this.mummy.animations.add('walk');

            this.mummy.animations.play('walk', 12, true);

 

            this.game.add.tween(this.mummy)

                .to({

                    x: 450

                }, 2500, Phaser.Easing.Linear.None)

                .to({

                    x: 580

                }, 2500, Phaser.Easing.Linear.None)

                .loop()

                .start();

 

            this.game.add.tween(this.mummy.scale)

                .to({

                    x: 1.2

                }, 100, Phaser.Easing.Linear.None, null, 2400)

                .to({

                    x: -1.2

                }, 100, Phaser.Easing.Linear.None, null, 2400)

                .loop()

                .start();

 

 

Any idea?

 

greetings!

post-6577-0-40779500-1391803322.jpg

Link to comment
Share on other sites



this.game.add.tween(this.mummy)
                .to({
                    scale: 1.2
                }, 100, Phaser.Easing.Linear.None, null, 2400)
                .to({
                    scale: -1.2
                }, 100, Phaser.Easing.Linear.None, null, 2400)
                .loop()
                .start();

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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