Jump to content

Pointer controls


Ilunyia
 Share

Recommended Posts

Hello,

 

Just starting out with Phaser as a bit of passing time out of work and got a little demo spaceship nicely flying around a big world with some background planets which currently moves its camera via keyboard, the question would be how would I go about to move the world camera with dragging the mouse/pointer?

 

Also, how would I go about detecting a double click/double tap?

 

And lastly even though this works, just seeing if there is a better way to rotate my space ship with tweening then this:

 

    var angle = game.physics.angleToPointer(ship, pointer);
    if (Math.abs(ship.rotation - angle) > Math.PI)
    {
        if (angle < 0)
        {
            angle = 2 * Math.PI + angle;
        }
        else
        {
            angle = - 2 * Math.PI + angle;
        }
    }
    var d = Math.abs(ship.rotation - angle) / Math.PI * 1000;
    rotationTween = game.add.tween(ship).to({ rotation: angle }, d);

 

 

Thanks a bunch for Phaser as this will be a nice pass time for off work.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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