Jump to content

Help with angleToPointer


DudeshootMankill
 Share

Recommended Posts

Well, i've hit another snag. I've given my player sprite a child, this is the gun and it tracks the mouse. Now if i turn left, and use scale.x -1 to flip the sprite the gun gets inverted aswell. 

I've got this so far

 if (cursorPos > 140) {
        arrow.rotation = game.physics.arcade.angleToPointer(player) - Math.PI; };

 

The gun is aimed to the left side but the rotation is inverted of the mouse position.

Hope anyone could point me in the right way again?

Link to comment
Share on other sites

I'm not an expert with Phaser or grouping but sounds like those elements should not be grouped together like that, or, more specifically, you'd want to only flip your player sprite and not the gun sprite attached to them.

Maybe you could group them so they are siblings and move their container around? That way they both share a common parent which tracks movement etc but you can only flip the actual player sprite inside when necessary. The gun would rotate as you currently are doing, presumably the gun flips too when the angle is within a certain range.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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