Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

How to merge TILED-created maps into Phaser


rohundhar
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...