javascript - Phaser.js : cannot read property '0' on tiled map layer -
i'm working paser.js on meteor.js server.
it worked wperfectly until try use tiled maps described here.
here code :
js :
if (meteor.isclient) { template.game.oncreated(function() { var game = new phaser.game(800, 600, phaser.auto, '', { preload: preload, create: create, update: update }); var map; var backgroundlayer; var blocklayer; var bg; function preload() { // load game assets // images, spritesheets, atlases, audio etc.. game.load.tilemap('mytilemap', 'assets/tilemaps/scifi.json', null, phaser.tilemap.tiled_json); game.load.image('mytileset', "assets/tilemaps/scifi_platformtiles_32x32.png"); } function create() { map = game.add.tilemap('mytilemap'); map.addtilesetimage('scifi_platformtiles_32x32', 'mytileset'); backgroundlayer = map.createlayer('background'); blocklayer = map.createlayer('blocklayer'); } function update() { } }); }
html :
<head> <meta charset="utf-8" /> <title>phaser - making first game, part 1</title> <script type="text/javascript" src="phaser.min.js"></script> <style type="text/css"> body { margin: 0; } </style> </head> <body> <h1>welcome first phaser game!</h1> {{> game}} </body> <template name="game"> <div id="phasercanvas"></div> </template>
and, when try on localhost:3000, :
uncaught typeerror: cannot read property '0' of undefined
from phaser.min.js:15. line generate warning
blocklayer = map.createlayer('blocklayer');
it seems phaser can correctly read 'background'
layer information scifi.json, not 'blocklayer'
one.
here extract scifi.json :
{ "height":20, "layers":[ { "compression":"zlib", "data": "[some long hashed key...]", "encoding":"base64", "height":20, "name":"background", "opacity":1, "type":"tilelayer", "visible":true, "width":20, "x":0, "y":0 }, { "compression":"zlib", "data":"[some long hashed key...]", "encoding":"base64", "height":20, "name":"blocklayer", "opacity":1, "type":"tilelayer", "visible":true, "width":20, "x":0, "y":0 }], "nextobjectid":1, [...]
and i'm stil unable find out what's problem... has faced before ?
more informations :
i use atom ide
i tried phaser v2.0.1 , phaser v2.4.2
thanks you.
seems problem came tiled : hashed key compressed zlib, though should not compressed @ phaser not support yet.
Comments
Post a Comment