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 trying to implement a zoom feature but I have a problem. I am zooming in and out a camera with a pinch gesture, I update the camera each time in the render, but my sprites keep their original position and don't change with the zoom in or zoom out.

The Libraries are from libgdx.

What am I missing?

private void zoomIn()
    ((OrthographicCamera)this.stage.getCamera()).zoom += .01;

public boolean pinch(Vector2 arg0, Vector2 arg1, Vector2 arg2, Vector2 arg3) 
    // TODO Auto-generated method stub
    return false;

public void render(float arg0) 

public boolean touchDown(int arg0, int arg1, int arg2) 
    this.stage.toStageCoordinates(arg0, arg1, point);
    Actor actor = this.stage.hit(point.x, point.y);

    if(actor instanceof Group)
        ((LevelSelect)((Group) actor).getActors().get(0)).touched();

    return true;

Zoom In Zoom In

Zoom Out Zoom Out

share|improve this question
First make sure that the camera is actually changing. Then make sure that you are applying the camera to the sprite. – Luis Estrada Mar 30 '12 at 23:07
Also, these types of questions are hard to answer with no context, code or screenshots. – Luis Estrada Mar 30 '12 at 23:08
what is your graphic API, what is your platform, what is the language? is the camera even moving – gardian06 Mar 30 '12 at 23:15
The zoom is actually working, because the image is zooming in and zooming out, but the position doesnt change, ill put the code – Rudy_TM Mar 30 '12 at 23:21
let us continue this discussion in chat – XiaoChuan Yu Mar 31 '12 at 0:21
up vote 2 down vote accepted

My best guess is that your sprites reside in the same world space as the camera does while your hit boxes (collision rects) reside in screen space. Your world space sprites are affected by the camera's zoom but screen space collision boxes are not.

Your best shot it to quantify your collision boxes in world space like your sprites are instead of screen space and then you will not have this problem.

share|improve this answer

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.