Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a game with large obstacle and sprites(in cocos2d+box2d for iPhone), then after zooming out my sprites and layer (by increasing cameraZ), I make my game to play by user, which causes some problem in touch detection of dynamic objects.

Can it be said a good approach to work with? If No then what will be the solution to work properly(consider that I have traveled so far with this approach)?

share|improve this question
up vote 1 down vote accepted

I'm not quite sure I understand your question entirely.

I'm guessing you're having problems because the Z of your camera changes and makes all your collision detection off.

If this is the case, you could try changing the FOV of the camera for the 'zoom' effect, this will remove any problems with the axis.

share|improve this answer
Well, please code, how to change the FOV. – rptwsthi Jun 1 '11 at 9:42
In your call to gluPerspective(), the first parameter is the FOV, probably 45 or 60. The higher this number is, the more the camera 'zooms-in'. – Jonathan Connell Jun 1 '11 at 9:45
[ setEyeX:0 eyeY:0 eyeZ:180];(i'm using this line for zooming out, putting camera far from my sprites by increasing z) – rptwsthi Jun 1 '11 at 9:48
Apparently you need to use the 'eye' property to scale instead of moving the camera. [ setEyeX:x2 eyeY:y2 eyeZ:zoomFactor]; Where zoomFactor is your zoom factor :P – Jonathan Connell Jun 1 '11 at 10:03
But i thought it is the only way to zoom out with proper touch detection(almost) – rptwsthi Jun 1 '11 at 10:07

Your Answer


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.