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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.