Jump to content

How to Tween Scale of a Container?


Ninjadoodle
 Share

Recommended Posts

Hi @enpu

I'm trying to tween the scale of a container, and I've tried every possible combination but nothing seems to work.

Setting the scale like this works fine ...

game.scene.mg.scale.set(2);

however when I try using a tween, nothing happens ...

game.Timer.add(250, function() {
    game.Tween.add(game.scene.mg, {
        scale: 2
    }, 500, {
        delay: 100,
        easing: 'Back.In',
    }).start();
});

I've also tried -> game.Tween.add(game.scene.mg.scale

as well as using scaleX: 2 and scaleY: 2 for the tween.

Thanks heaps in advance!

Link to comment
Share on other sites

@Ninjadoodle

https://www.panda2.io/docs/api/Container
If you look at Container documentation, you can see that the scale property is Vector.

https://www.panda2.io/docs/api/Vector
Then if you take a look at Vector class, you can see it has properties x and y. Those are the properties that you should tween.

https://www.panda2.io/playground#tween-basic
Just like in this basic Tween example we are tweening position property's x and y values, and position is also Vector. So it's just the same for scale:

var tween = new game.Tween(container.scale);
tween.to({ x: 2, y: 2 }, 2000); // Scale container to 200% in 2 seconds
tween.start();

Makes sense?

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.

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

  • Recently Browsing   0 members

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