kurhlaa Posted September 23, 2018 Share Posted September 23, 2018 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 More sharing options...
samme Posted September 23, 2018 Share Posted September 23, 2018 getLayer just converts a layer identifier into the actual layer contents. If you read the method like this it makes a little more sense: var layerData = this.getLayer(layer); if (layerData === null) { return null; } return TilemapComponents.HasTileAt(tileX, tileY, layerData); Link to comment Share on other sites More sharing options...
kurhlaa Posted September 23, 2018 Author Share Posted September 23, 2018 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 More sharing options...
Recommended Posts