这可能是一个愚蠢的问题,然而,我无法在任何地方找到答案。我按照这个post来扩展舞台。
public void resize (int width, int height) {
Vector2 size = Scaling.fit.apply(800, 480, width, height);
int viewportX = (int)(width - size.x) / 2;
int viewportY = (int)(height - size.y) / 2;
int viewportWidth = (int)size.x;
int viewportHeight = (int)size.y;
Gdx.gl.glViewport(viewportX, viewportY, viewportWidth, viewportHeight);
stage.setViewport(800, 480, true, viewportX, viewportY, viewportWidth, viewportHeight);
}
但是,Eclipse显示以下错误消息。任何的想法? libgdx版本0.9.8。 “Stage类型中的方法setViewport(float,float,boolean)不适用于参数(int,int,boolean,int,int,int,int)”
答案 0 :(得分:0)
mystage = new Stage(scrw, scrh, false);
scrw是视口的宽度,
scrh是查看端口的高度。
这对我来说很顺利..
答案 1 :(得分:0)
API已更改,以下是新代码:
Stage stage;
public void create() {
stage = new Stage(
new StretchViewport(
Gdx.graphics.getWidth(),
Gdx.graphics.getHeight()
)
);
}