phaser-animated-tiles
phaser-animated-tiles copied to clipboard
Received error when loading my map
I received the following error when calling this.animatedTiles.init
Uncaught TypeError: Cannot read property 'type' of null
What I found was that if there is a layer in the tile map JSON which has not been added to the map using Phaser APIs (createStaticLayer/createDynamicLayer) then that layer will not have a 'Type' property and the animatedTiles.init fails.
Since this plugin requires animated layers to by DynamicLayers I changed line of code 410 in AnimatedTiles.js from this:
if (layer.tilemapLayer.type === "StaticTilemapLayer") {
to this:
if ((!layer.tilemapLayer) ||
(!layer.tilemapLayer.type) ||
(layer.tilemapLayer.type === "StaticTilemapLayer")) {
This fixed my issue because my animatedTiles.js is ignoring all layers that are not dynamic however I wanted to share this in case others hit this issue.
Thanks for sharing