Jump to content

Problems with measuring angle


Recommended Posts

I have this circle right now:


And player is able to rotate the arrow. And when it stops, I want to measure the angle between arrow's head and that black horizontal line in the middle of the centre.


Arrow has these properties:

arrow = game.add.sprite(380, 300, 'arrow');
arrow.anchor.setTo(0.5, 0.5);
game.physics.enable(arrow, Phaser.Physics.ARCADE);
arrow.body.maxAngular = 500;
arrow.body.angularDrag = 50;
This is the line in update method:
reachMessage.setText('Angle: ' + game.physics.arcade.angleToXY(arrow, 380, 300));
The problem is, that it always shows 0. I guess this is because my arrow's anchor is 0.5, but I must set that cause I want to spin arrow from center. What I want to do is measure angle between arrow's head and XY. I tried to change arrow's anchor to 0.5, 0.1 before measuring angle, but it doesn't work. 
How can I achieve that?
Thank you, for your help.
Link to comment
Share on other sites

  • 2 months later...

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...