Take the 2-minute tour ×

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

1 Answer 1

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


