phaser-animated-tiles icon indicating copy to clipboard operation
phaser-animated-tiles copied to clipboard

Received error when loading my map

Open dlentz-ibm opened this issue 5 years ago • 1 comments
trafficstars

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.

dlentz-ibm avatar May 23 '20 18:05 dlentz-ibm

Thanks for sharing

blopa avatar Sep 26 '21 08:09 blopa