Jump to content

Undefined object error coming for basic tiled implementation


Recommended Posts

        <title>Phaser Tiled Test</title>
        <div id="renderer_container">
            <!-- /renderer_container -->
        <script src="phaser.min.js"></script>
        <script src="main.js"></script>
var map;
var layer;
var keyArrow;

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'renderer_container', {
		preload : preload,
		create : create,
		update : update,
		render : render

function preload() {

	game.load.tilemap('map', 'testMap.json', null, Phaser.Tilemap.TILED_JSON);
	game.load.image('tiles', 'map.png');


function create() {

	map = game.add.tilemap('map');

	//  Now add in the tileset

	//  Create our layer
	layer = map.createLayer(0);

	//  Resize the world

	//  Allow keyArrow to scroll around the map
	keyArrow = game.input.keyboard.createCursorKeys();

	var help = game.add.text(16, 16, 'Arrows to scroll', {
			font : '14px Arial',
			fill : '#ffffff'
	help.fixedToCamera = true;

function update() {
	if (keyArrow.left.isDown) {
		game.camera.x -= 4;
	} else if (keyArrow.right.isDown) {
		game.camera.x += 4;

	if (keyArrow.up.isDown) {
		game.camera.y -= 4;
	} else if (keyArrow.down.isDown) {
		game.camera.y += 4;


function render() {}


Just learning phaser. I am trying to load a simple tiled map.

But i am getting an undefined exception for the "map" object.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Try to add the name of tile set what you give in tiled editor, like this example:


    //  The first parameter is the tileset name, as specified in the Tiled map editor (and in the tilemap json file)
    //  The second parameter maps this name to the Phaser.Cache key 'tiles'

    map.addTilesetImage('SuperMarioBros-World1-1', 'tiles');




Link to comment
Share on other sites

Hi Man,


Sory but i cant run your project, i dont know how it work because i dont create it ..


I am not sure, but when i try to run isometric map in phaser i cant to do it because that map was unavailable, but maybe someone who knows more can tell You something.

Try this course, i was started using phaser with it:



Link to comment
Share on other sites


I only copied your code and used your files externally and got some errors in console.

phaser.min.js:11   Phaser v2.4.6 | Pixi.js v2.2.9 | WebGL | WebAudio     http://phaser.io ♥♥♥
phaser.min.js:25 TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser
phaser.min.js:20 TypeError: Cannot read property 'length' of undefined(…)f.onload @ phaser.min.js:20
main.js:44 Uncaught TypeError: Cannot read property 'left' of undefined

Well unless I missed something from your posts I can even replicate the same error you get.


Link to comment
Share on other sites

I updated my version of Phaser and I am getting the same error as your are.

I am beginning to think this is the culprit - "TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser"

My map is staggered isometric. :(


Link to comment
Share on other sites


  • Recently Browsing   0 members

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