Jump to content

Scaling a map without affecting the placement of a sprite


Recommended Posts

So I am having a problem whenever I am zooming out the map. The scale of all the assets are done correctly except when I zoom out, their position on the map change. I am not changing sprite.x/y, it is just that when the map is scaling things move around and I tried doing something like

//pseudo-codeif(zoomOut){  sprite.x *= scale;  sprite.y *= scale;}

but that didn't work since that sent the sprites off the map eventually.


Here's an example of what is going on.


So this is the game when zoom is maxed out (scale=1)




this is when the scale is 0.9 (you can see the sprites aren't where they were originally placed)




At scale=0.7 (now it is even more obvious)




What do you guys think?

Link to comment
Share on other sites


I added the sprites to a screen group and scaled accordingly :


game.input.onDown.add(function() {    scale -= 0.1    screenGroup.scale.setTo(scale, scale);}, this);
Hope this helps


Thank you! That's perfect! I was scaling the sprites individually. Adding them to a group is smarter and easier to handle! :)

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.

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.
  • Create New...