Jump to content

Tank turret rotation


ith
 Share

Recommended Posts

Hi,

 

I'm making a basic 2D top down tank game. I have a problem with grouped sprite rotations.

 

The player group has three sprites, shadow, tank body and turret:

player = game.add.group();player.add(shadow);player.add(tank);player.add(turret);

The turret should face to the mouse pointer at all times. It is done so:

turret.rotation = game.physics.arcade.angleToPointer(player);

But when I rotate the player, the turret is no longer facing the mouse pointer:

if (keys.left.isDown) {  player.angle -= 4;} else if (keys.right.isDown) {  player.angle += 4;}

It seems that the turret rotation stays fixed to player rotation. What should I do, that the turret is facing the mouse pointer?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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