我有一个多游戏项目。我有一个 menu.js
和很多游戏 js 页面。
在menu.js
加载页面中, View 是正确的。加载我的 game.js
并返回 menu.js
后,屏幕不一样。我尝试了很多解决方案,但没有任何效果。我想从一开始就展现出同样的外观。
game.js
之前的
加载game.js
后的
menu.js 的一部分
var menuState = {
create: function(){
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.setGameSize(1000, 600);
game.scale.minWidth = 300;
game.scale.minHeight = 180;
game.scale.maxWidth = 1000;
game.scale.maxHeight = 600;
game.scale.pageAlignHorizontally = true;
game.scale.pageAlignVertically = true;
game.scale.updateLayout(true);
game.state.start("game");
},
start: function(){
}
}
game.js 的一部分
this.map = game.add.tilemap('level2');
this.map.addTilesetImage('secondMap');
this.map.setCollisionByExclusion([13, 14, 15, 16, 46, 47, 48, 49, 50, 51]);
this.map.setTileIndexCallback(225, this.test3, this);
this.map.setTileIndexCallback(228, this.test, this);
this.map.setTileIndexCallback(231, this.test2, this);
this.layer = this.map.createLayer('Tile Layer 1');
this.layer.resizeWorld();
如果我删除 this.layer.resizeWorld();
并返回主页,外观是正确的,而且我认为是 map
导致返回外观不好。
我已经尝试过:
this.layer.destroy();
this.map.destroy();
game.world.removeAll()
game.state.clearCurrentState();
但结果总是相同。
如果我使用:
game.state.destroy();
game.destroy();
删除全部。
我不明白问题出在哪里。
最佳答案
我也遇到了类似的问题,但是我在 Google 中找到了解决方案这对我很有帮助(就我而言),并将认真地重新定义世界的界限:
this.game.world.setBounds(0, 0, this.game.width, this.game.height);
关于javascript - Phaser.js |在更改状态之前删除图 block map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42224386/