TomLeGrand Posted January 15, 2018 Share Posted January 15, 2018 Hi, I'm currently making a litlle top-down shooter game with Phaser. I'm using the method bellow to aim towards the mouse's position. sprite.rotation = game.physics.arcade.angleToPointer(sprite); This work very well, but I would like to allow the player to zoom in and out. I was following this idea : http://jsfiddle.net/NMNJ7/25/ which use the game.world.scale.set() method; But when I change the world's scaling, the angleToPointer() method is completly lost and it's impossible to aim. You can try this little exemple I've made to understand what goes wrong : https://jsfiddle.net/TomLeGrand/uh7d10eu/127/ Do someone has an idea to fix this? Thanks for you futur help Link to comment Share on other sites More sharing options...
in mono Posted January 15, 2018 Share Posted January 15, 2018 Just played with it and apparently you have to also scale the input. As weird as it is, you don't need the same scale, but the reciprocal of it. game.input.scale.set(1 / 1.35); P.S. Call this just after setting the world's scale. P.S.2 This assumes you have "square" scaling, i.e. scale.x === scale.y TomLeGrand 1 Link to comment Share on other sites More sharing options...
TomLeGrand Posted January 15, 2018 Author Share Posted January 15, 2018 Cool it works well 11 hours ago, in mono said: P.S.2 This assumes you have "square" scaling, i.e. scale.x === scale.y By that do you mean that my world's scaling need to be equal on height and on width ? This is a link to the fixed example : https://jsfiddle.net/uh7d10eu/134/ Link to comment Share on other sites More sharing options...
in mono Posted January 16, 2018 Share Posted January 16, 2018 15 hours ago, TomLeGrand said: Cool it works well By that do you mean that my world's scaling need to be equal on height and on width ? Yes, exactly. Any .set() you do on a Phaser.Point with only one argument, it applies that argument to both x and y. It's unlikely that they'd be different, just thought I'd mention it. By the way, if you don't mind me asking, what's your aim with scaling the whole world? What are you trying to achieve? Link to comment Share on other sites More sharing options...
TomLeGrand Posted January 16, 2018 Author Share Posted January 16, 2018 I want to allow the player to see farthest depending on the weapon the player carrying. If the player use a sniper, he can see further than an other weapon (I hope you understand, english isn't my mother langage) I've got an other topic Other problems I have, have been resolved. You can try the example in this topic to see more about what I'm trying to achieve Link to comment Share on other sites More sharing options...
in mono Posted January 17, 2018 Share Posted January 17, 2018 Yup, I got it now. Maybe the more "correct" approach would be to play with the camera, not with the world (as seen from the other topic this introduces other problems), but this is just what I would try. Link to comment Share on other sites More sharing options...
Yazaa Posted February 23, 2018 Share Posted February 23, 2018 I'm applying the same fix to my little project but it doesn't work. I am using arcade.moveToPointer, trying different combinations of changing scale of input, world and camera don't work. I also tried 1/scale for input, but it doesn't work. player.rotation = game.physics.arcade.moveToPointer(player, 256); game.camera.scale.set(scale) game.input.scale.set(1/scale) The position the sprite is heading to is still offset. Everything is fine on scale 1. Yes! Got it working properly. You have to set camera scale to 1/scale not the input. Edit. It doesn't work when changing the position of the camera. The problem is still there. Link to comment Share on other sites More sharing options...
Recommended Posts