Fix position after scale

Recommended Posts

Hi guys.

I'm trying to do a "zoom in" effect on a GUI_Object. But when scaling the image leaves the original collision field. How to keep the image centered with the collision field of the button?


Before click:


After click:



game.UI.ButtonInit = me.GUI_Object.extend({
    init: function (x, y, image) {
        this._super(me.GUI_Object, "init", [x, y, { image: image, }]);

        this.anchorPoint.set(0, 0);
        this.floating = false;

    onClick: function () {
        this._super(me.Sprite, "scale", [.8, .8]);

    update: function () {
        return true;

    draw: function (renderer) {
        this._super(me.GUI_Object, "draw", [renderer]);


Share this post

Link to post
Share on other sites

If you are using the collision shapes for pointer events, you can create a plugin to patch me.input.globalToLocal() to apply the same scaling transformation. This won't make the debugPanel render the collision shapes scaled, but your plugin could also patch the debugPanel's draw method to apply the scaling transformation, if you needed to.

If, however, you aren't using pointer events, why would you want to scale the collision shapes at all?

Share this post

Link to post
Share on other sites

this should be fixed in the latest dev branch (-> 5.1 to be released within a few days), here an link to the latest build :

make sure to also update the debugPanel to the latest version if you want to give it a try before the release :

Share this post

Link to post
Share on other sites

i thinks this is still not fixed

var scale =
   mul : 1,

this.TweenScale = new me.Tween(scale).to({mul:1.01}, 500).
   this.scale(scale.mul, scale.mul);


here is the result, see the big purple circle, when scaling its position changed

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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.