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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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