全部博文(315)
分类: Android平台
2015-03-15 21:40:52
Stage类的API增加了viewport,有两种viewport,一种Scale,一种Extend,一种按尺寸铺满,一种全铺满,原文如下:
If your old Stage construction code looked like this:
stage = new Stage(width, height, false); // OR
stage.setViewport(width, height, false);
Then you need to change it to:
stage = new Stage(new StretchViewport(width, height)); // OR
stage.setViewport(new StretchViewport(width, height));
If your old code looked like this:
stage = new Stage(width, height, true); // OR
stage.setViewport(width, height, true);
Then you need to change it to:
stage = new Stage(new ExtendViewport(width, height)); // OR
stage.setViewport(new ExtendViewport(width, height));
There is another important change, resize used to look like:
public void resize (int width, int height) {
stage.setViewport(width, height);
}
Now you’ll do this:
public void resize (int width, int height) {
stage.getViewport().update(width, height, true);
}
The boolean centers the camera if true (only really needed for UIs). It can be omitted, which is the same as false.