[英]libgdx why stage camera is not moving?
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. 因此,到目前为止,我在游戏中使用的是libgdx的舞台类,因此我在舞台上添加了一个演员,该演员只是为屏幕绘制背景。我遇到的问题是,当我移动舞台的摄像头以模拟屏幕上的滚动时,背景图像大于屏幕),相机将不会移动。 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.
我不知道这是否是一个错误原因,我认为很奇怪,它仅适用于桌面启动器,是的,android启动器和桌面启动器都使用相同的ApplicationListener实例进行了初始化。 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();
}
我只是意识到这确实是我的其他功能中的一个问题,该问题并未更新相机的位置,因此它与libgdx无关,对不起,我希望我可以删除该问题,但是很奇怪,它正在桌面上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.