How do I properly implement zooming in my game?

Posted by Rudy_TM on Game Development See other posts from Game Development or by Rudy_TM
Published on 2012-03-30T23:05:44Z Indexed on 2012/03/30 23:43 UTC
Read the original article Hit count: 171

Filed under:
|

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

    zoomIn();


    return false;
}

public void render(float arg0) 
{
    this.gl.glClear(GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_COLOR_BUFFER_BIT);
    ((OrthographicCamera)this.stage.getCamera()).update();
    this.stage.draw();


}

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

© Game Development or respective owner

Related posts about camera

Related posts about libgdx