我已经尝试过:
graphics().setSize(800, 600);
但是它没有效果(至少在Java和HTML中)。
而且这种方法似乎已经过时了。那么设置游戏尺寸的最佳方式是什么?
我已经尝试过:
graphics().setSize(800, 600);
但是它没有效果(至少在Java和HTML中)。
而且这种方法似乎已经过时了。那么设置游戏尺寸的最佳方式是什么?
在PlayN的1.5版本中,此方法已被弃用。在Android/iOS上,游戏视图的大小由设备决定;在Java上,可通过JavaPlatform.Config进行配置;在HTML中,可通过playn-root div的大小进行配置。
例如,在Java后端:
public class GameJava {
public static void main(String[] args) {
//Setting the size of the Java Backend
Config config = new Config();
config.width = 800;
config.height = 480;
JavaPlatform platform = JavaPlatform.register(config);
platform.assets().setPathPrefix("your/package/resources");
PlayN.run(new Game());
}
}
对于HTML,可以像这样做:
<style>
#playn-root {
width: 640px;
height: 480px;
}
</style>
....
<div id="playn-root"></div>
<body>
<script src="game/game.nocache.js"></script>
</body>