【发布时间】:2017-07-02 15:19:36
【问题描述】:
我有一个多游戏项目。我有一个menu.js 和很多游戏 js 页面。
在menu.js 加载页面中,视图是正确的。加载我的game.js 并返回menu.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(); 并返回 home 外观是正确的,我也认为是 map 使返回外观不好。
我试过了:
this.layer.destroy();
this.map.destroy();
game.world.removeAll()
game.state.clearCurrentState();
但总是相同的结果。
如果我使用:
game.state.destroy();
game.destroy();
是全部删除。
我看不出问题出在哪里。
【问题讨论】:
标签: javascript jquery phaser-framework