Sign in to follow this  
makalu

How to tween scale in Phaser 3

Recommended Posts

In Phaser 2 we could tween scale like in the topic linked below.  How is this done in Phaser 3?

It looks like the sprite Scale property has changed to scaleX and scaleY, which I thought maybe I could tween like this, but this didn't seem to work:

this.scene.tweens.add({
targets     : [ this.scaleX, this.scaleY ],
x: 10,
y: 10,
ease        : 'Linear',
duration    : duration,
yoyo        : false,
repeat      : 0,
callbackScope   : this
});

 

 

Share this post


Link to post
Share on other sites

Just figured it out, using scaleX and scaleY... 

this.scene.tweens.add({
  targets     : [ this ],
  scaleX: 10,
  scaleY: 10,
  ease        : 'Linear',
  duration    : duration,
  yoyo        : false,
  repeat      : 0,
  callbackScope   : this
});

Share this post


Link to post
Share on other sites
On 10/21/2018 at 4:51 AM, makalu said:

Just figured it out, using scaleX and scaleY... 


this.scene.tweens.add({
  targets     : [ this ],
  scaleX: 10,
  scaleY: 10,
  ease        : 'Linear',
  duration    : duration,
  yoyo        : false,
  repeat      : 0,
  callbackScope   : this
});
this.scene.tweens.add({
  targets     : this ,
  scale       : 10
  ease        : 'Linear',
  duration    : 500,
});

You can simplify it.
targets only needs to be an array if it's multiple targets.
scale: 1 does both X&Y
yoyo default is false, as 0 of repeat and "this" of callbackScope. :)

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.