Batzi Posted October 27, 2015 Share Posted October 27, 2015 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 More sharing options...
megmut Posted October 27, 2015 Share Posted October 27, 2015 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); See: http://phaser.io/sandbox/zmRXIPjS Hope this helps Batzi 1 Link to comment Share on other sites More sharing options...
Batzi Posted October 27, 2015 Author Share Posted October 27, 2015 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); See: http://phaser.io/sandbox/zmRXIPjS 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 More sharing options...
jmp909 Posted October 28, 2015 Share Posted October 28, 2015 I had assumed you might not want to scale the sprites, but you appear to have fixed what you need I had made this anyway as a rough test in that casehttp://phaser.io/sandbox/GKTRPIOi/play W,A,S,D and NumPad +/- to scale I should probably have used the camera though instead of shifting the map microspace and Batzi 2 Link to comment Share on other sites More sharing options...
Recommended Posts