Giter Club home page Giter Club logo

phaser-animated-tiles's People

Contributors

apther avatar dependabot[bot] avatar fusol13 avatar imsys avatar lackhand avatar nkholski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phaser-animated-tiles's Issues

tiled v1.2.0

After editing the map using the latest version of tiled, the plugin doesn't work

Layers in new versions of Phaser

Hey, in new versions of Phaser they got rid of layer types. So checking for static type now is breaking plugin.
Plugin just needs a little bit of code to work, i added request if someone is instrested.

Updates / Compatibility?

It seems like this plugin is not working for the latest version of Phaser (Phaser 3.21. 0). I can see the original changes that broke the plugin in newer Phaser versions was resolved, but I am still unable to see animated tiles, although there are no thrown errors?

`import AnimatedTiles from 'phaser-animated-tiles/dist/AnimatedTiles';

let Water: Phaser.Tilemaps.DynamicTilemapLayer;
export default class ForestC extends Phaser.Scene {
public player: Player;
public cursors: Phaser.Types.Input.Keyboard.CursorKeys;
public controls: Controls;
public spawn: any;
public direction: any;

constructor() {
super({
key: 'ForestC',
});
this.spawn = null;
this.direction = null;
}

preload(): void {
this.load.scenePlugin('AnimatedTiles', AnimatedTiles, 'animatedTiles', 'animatedTiles');
this.load.spritesheet('player', '../../../assets/character/player.png',
{
frameWidth: 16, frameHeight: 32, margin: 0, spacing: 0,
});
this.load.image('tileset2', '../../../scenes/maps/source2.png');
this.load.image('tileset3', '../../../scenes/maps/source3.png');
this.load.tilemapTiledJSON('ForestC', '../../../scenes/maps/ForestC/ForestC.json');
}

init(data): void {
this.spawn = data.spawn || { x: 100, y: 100 };
this.direction = data.direction || 'down';
}

create(): void {
// Parse map
const tilemapLayers = [];
const map = this.make.tilemap({ key: 'ForestC' });
const tilemap = map.addTilesetImage('tileset2', 'tileset2', 16, 16, 1, 2);
// Layers
const Grass = map.createDynamicLayer('Grass', tilemap, 0, 0);
Water = map.createDynamicLayer('Water', tilemap, 0, 0);
console.log((this as any).animatedTiles);
(this as any).animatedTiles.init(map);
}

update(): void {
Water.fill(362, 0, 16, 20, 4);
(this as any).animatedTiles.updateAnimatedTiles();
}
}
`

Plugin crash if map contains an unused layer.

When using the plugin with a map containing an unused layer (eg. only used on server side), the plugins throws an error.

Uncaught TypeError: Cannot read property 'type' of null.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.