Jump to content

Tweening Camera Movement


Sunburned Goose
 Share

Recommended Posts

Here is a demo of the work.  If you thrust the ship to the lower right, there is a planet that it will try to orbit.  The camera will move from the ship to the planet when the ship enters it's sphere of influence.  I want to make this transition smooth, as if the camera was lifting from the ship and landing on the planet, all the while keeping both objects within the camera's frame.

 

http://pgl.tiedtheleader.com/

Link to comment
Share on other sites

I ended up working this out tonight.

// If my camera is already following a targetif (that.game.camera.target) {  that.game.camera.follow(null);  // Unfollow the target  that.game.add.tween(that.game.camera).to( {x: pCenter.x - (that.game.camera.width / 2), y: pCenter.y - (that.game.camera.height / 2) }, 750, Phaser.Easing.Quadratic.InOut, true);  // Move the camera to the center of a planet, adjusting for the camera being 'centered' at the top-left.}
Link to comment
Share on other sites

  • 3 weeks later...
 Share

  • Recently Browsing   0 members

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