Todi Posted September 24, 2015 Share Posted September 24, 2015 Hey guys! So, always I try to get the real coordinates of my entities in the map, using <layer>.getTileX/Y, I get this error message: "getTileX/Y is not a funcition". Or, when I try to log the function in the console, I receive the message "undefined". What I am doing wrong? var layer = this.map.layer;console.log(layer.getTile); // undefinedvar layer = this.map.layers[0];console.log(layer.getTileX); // undefinedconsole.log(layer.getTileY); // undefinedThanks! Link to comment Share on other sites More sharing options...
rich Posted September 24, 2015 Share Posted September 24, 2015 getTileX is a property of Phaser.Tilemap, not Phaser.TilemapLayer. Link to comment Share on other sites More sharing options...
Todi Posted September 24, 2015 Author Share Posted September 24, 2015 getTileX is a property of Phaser.Tilemap, not Phaser.TilemapLayer. I am following the Phaser Docs, and there said the getTileX is a method from TilemapLayer! http://phaser.io/docs/2.4.3/Phaser.TilemapLayer.html#getTileX What I am trying is get the coordinates from matrix for use in EasyStar plugin. EDIT: Nevermind! I solved! Link to comment Share on other sites More sharing options...
rich Posted September 24, 2015 Share Posted September 24, 2015 Ah yes so it is In that case I think the problem is simply that you're using it as a property rather than a function. Should be `layer.getTileX(v)` where v is the pixel coordinate. Link to comment Share on other sites More sharing options...
Todi Posted September 24, 2015 Author Share Posted September 24, 2015 Ah yes so it is In that case I think the problem is simply that you're using it as a property rather than a function. Should be `layer.getTileX(v)` where v is the pixel coordinate. So, in the create method of the level, I got the createLayer return, that is a TilemapLayer, and now it works! What I done before, was get the layer (TilemapLayer) from <Tilemap>.layers[0] (my test path) but it didn't work, do you know why? Link to comment Share on other sites More sharing options...
rich Posted September 24, 2015 Share Posted September 24, 2015 That's raw layer data, not an array of TilemapLayer objects. Link to comment Share on other sites More sharing options...
Todi Posted September 25, 2015 Author Share Posted September 25, 2015 That's raw layer data, not an array of TilemapLayer objects. Thanks, Rich! Link to comment Share on other sites More sharing options...
Recommended Posts