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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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