Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Creating a little LoZ inspired game in Java here just to get into the feeling of things (learning CS at my school but the only teacher who's willing to help is travelling for 6-months, so I'm teaching myself in the meantime). Thing is, I've run into a little snag with the functionality of the "camera".

I've so far been able to successfully limit where the camera goes in terms of the level size (stopping the camera when it gets to top, bottom, left, and right edges of the level), and keep the camera centered on the player as he moves around the level. The issue I'm having is that once my camera stops moving, I can't figure out how to wait until the player is in the center of the screen again for the camera to move again.

So if my player starts out in the center of the map and then moves all the way to the top left, if I move down or right then my sprite isn't in the center of the camera anymore.

Anyone have any suggestions? And sorry if this blatantly obvious, I'm still new to game development.

Thanks. ^^

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Just add some extra if statement that will prevent camera movement until the sprite is in the middle. Like:

If player is below middle and camera is at the bottom of the map don't move

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.