Jump to content

Using Camera focusOn to move to sprite currently out of view


nosenseworrying
 Share

Recommended Posts

Here's what I'm trying to accomplish:


  • Game world size 1200x900
  • Game view / Camera view size 800x600
  • Freely move camera around world with keyboard arrows
  • Load characters in various places around the map
  • Select from a list of character thumbnails and move the camera to focus on that character (wherever they are on the map)

I've got the basic functionality in play, and I'm using the Camera focusOn() method to move the camera to the selected character (based on the thumbnail clicked), however here is the issue: When the camera has the selected character in the current view, all is well. But, when the character is out of the current view (if you move the camera with the keyboard so that the selected character is completely out of view), the character sprite itself gets moved after the focusOn() call to the 0,0 coordinate of the rectangle representing the previous view.


Is there some attribute I need to set on the camera and/or sprite so that I can call focusOn() and only move the camera, leaving the sprite at its current coordinates, even if they're currently out of view?


Please let me know if I can further clarify... Thanks for your time and your help!


Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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