rohundhar Posted October 5, 2015 Share Posted October 5, 2015 Hey everyone! I am a student, beginner-intermediate programmer starting to get into game development using Phaser. I'm looking to import my own personally-designed maps/tilesets from TILED and I've looked all over for tutorials but I still can't seem to get it working. I've made my main_game.js file essentially just a skeleton file that will display my map. The error I'm getting from the error console( Chrome developer tools) is :Uncaught TypeError: Cannot read property '0' of undefined Anyone have any idea as to how this could be happening or what could be wrong with my declarations? The paths to both my .png and .json files is correct and I'm fairly sure i've saved those files correctly. The code I have so far is: var boundsx = 800, boundsy = 600;var game = new Phaser.Game(boundsx, boundsy, Phaser.AUTO, "game", {preload:preload, update:update, create:create});function preload(){game.load.tilemap('MyTilemap', 'firstMap.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tiles', 'terrain_atlas.png');}var map;var layer;function create(){map = game.add.tilemap('MyTilemap'); map.addTilesetImage('tiles', 'tiles'); layer = map.createLayer('MyTerrain'); layer.resizeWorld(); }function update(){} Link to comment Share on other sites More sharing options...
Skeptron Posted October 6, 2015 Share Posted October 6, 2015 Could you paste the JSON for the map? Maybe it's malformed. Link to comment Share on other sites More sharing options...
Cudabear Posted October 6, 2015 Share Posted October 6, 2015 Make sure Tiled is actually saving in JSON format. I'm pretty sure it saves as some other format by default. Link to comment Share on other sites More sharing options...
Recommended Posts