Jump to content

Strange rewriting of a variable at Tilemap.js


kurhlaa
 Share

Recommended Posts

Hello,

I was looking at the source code of Tilemap.js (https://github.com/photonstorm/phaser/blob/master/src/tilemaps/Tilemap.js) and I see strange rewriting of the layer variable all the time. For example:

hasTileAt: function (tileX, tileY, layer)
{
    layer = this.getLayer(layer);

    if (layer === null) { return null; }

    return TilemapComponents.HasTileAt(tileX, tileY, layer);
},

Could you tell more what is the idea to sent layer as an argument and then rewrite it with itself in the very beginning?

 

Link to comment
Share on other sites

Probably variables names are a little confusing. Also according to the docs getLayer() accepts:

  • string
  • integer
  • Phaser.Tilemaps.DynamicTilemapLayer
  • Phaser.Tilemaps.StaticTilemapLayer

but hasTileAt() (by docs) itself takes {Phaser.Tilemaps.LayerData} as param and sends it to the getLayer(). So my first thought was that it takes LayerData to get LayerData :)

Probably docs should be fixed and hasTileAt() (and all similar functions) accepts the same types like getLayer() mentioned before? 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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