Buttons that are not affected by camera scale or position

Recommended Posts


I implemented a two finger zoom using the propierty to zoom the game. I also implemented a drag functionality using and propierties.

But now I need to add static floating sprites, such that they are always in the same position on the screen regardless the zoom or the drag movement. But when I add them as sprites (game.add.sprite) they are affected by the camera propierties (x,y,scale). I read this and set fixedToCamera to true, it works partially, the (x,y) is static, but the when I zoom in (increase the size of the floating sprites also increases.

Is there any way I could add sprites that are not dependent on the camera?


Share this post

Link to post
Share on other sites

I finally found a way!. As mentioned here the Stage is "above" of the World. So placing an element there won't be affected by the world dynamics (in my case, the camera). So what I did was to add a group in the stage and then add the sprites to that group. As simple as that. The code:


var buttonsGroup =, "buttonsGroup", true);

var theSprite = buttonsGroup.create( x, y, "spriteName" );

The arguments of the group method are described here, the first is the parent and the last is a boolean value to indicate if the group should be added to the stage.

I hope it will be useful to anyone :)


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.