0
我一直试图让加载到移相器,我导出为JSON从一个瓷砖tilemap的,但它一直引起以下错误,当我添加:试图装入一个被tilemap的原因类型错误
我试图复制Phaser示例并更改字符串以匹配我的文件,以查看它是否是我做错的事 - 仍然没有工作。
代码:
window.onload = function() {
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phasergame', {preload: preload, create: create, update: update, render: render });
var map;
var layer;
function preload() {
game.load.tilemap('map', 'assets/tilemap/maze.json', null, Phaser.Tilemap.TILED_JSON);
game.load.image('tiles', 'assets/tilemap/tiles.png');
}
function create() {
map = game.add.tilemap('map');
map.addTilesetImage('tiles',tiles);
layer = map.createLayer('Walls');
layer.resizeWorld();
}
function update() {}
function render() {}
};
body {
background: black;
margin: 0;
padding: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.js"></script>
我maze.json从瓷砖:https://gist.github.com/spideynn/efe8e787031ffae89ddb354db129fb53
我tiles.png:http://i.imgur.com/8cw9DcC.png
Tiled中的tileset和图像名称相同 – Spideynn
@Spideynn你确定你有同名吗?在你的[JSON](https://gist.github.com/spideynn/efe8e787031ffae89ddb354db129fb53#file-maze-json-L44)文件中,它表示tileset的名称是* tiles.png *,而您正在加载的tileset有名称* tilemap.png * – 2016-12-10 08:46:20
我更新了原始帖子中使用的代码 - 我很确定我现在使用的是相同的名字 – Spideynn