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

TilemapLayer getTileX/Y is undefined


Todi
 Share

Recommended Posts

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); // undefined
var layer = this.map.layers[0];console.log(layer.getTileX); // undefinedconsole.log(layer.getTileY); // undefined

Thanks!

Link to comment
Share on other sites

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!  :huh:

 

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

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

 Share

  • Recently Browsing   0 members

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