So I am using libgdx’s stage class for my game so far I added an actor to the stage which just draws a background for the screen, the problem I’m having is that when I move the stage’s camera to simulate a scroll through the screen (the background image is larger than the screen) the camera won’t move. Now what is driving me crazy is that it DOES work when I run in on the desktop launcher, but whenever I run it on the phone it just won’t scroll. I really don’t know what could be the problem. I ensued that the method that moves the camera gets called cause I am logging the method’s name to the log cat whenever it gets called and it does get called. Also, I even logged the camera’s position and it changes but only if I run on the desktop, if I run on the phone it logs the same position. I don’t know if this is a bug cause I think is quite strange that it only works on the desktop launcher, and yes both the android launcher and the desktop launcher are initialized with the same ApplicationListener instance. Any suggestions? Thanks in advance.
Here is the simplified code:
public void Create()
{
GameStage = new Stage(2000, 2000, true);
GameCamera = new OrthographicCamera(2000, 2000);
GameCamera.setToOrtho(true, 2000, 2000);
GameStage.setCamera(GameCamera);
GameStage.setViewport(2000, 2000, true);
}
public void MoveCamera()//it gets called when user drags across the screen
{
GameStage.getCamera().translate(x, y, 0);
GameStage.getCamera().update();
}
public void render()
{
//the background actor has been added at this point
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
GameStage.act(Gdx.graphics.getDeltaTime());
GameStage.draw();
}
I just realized it was indeed a problem in other of my functions which wasn’t updating the camera position, so it has nothing to do with libgdx sorry I wish I could delete the question, it is strange it was working on the desktop though.