Jump to content

Problem with world.scale.set() and angleToPointer()


Recommended Posts


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

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

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

  • 1 month later...

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);


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

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...