nkholski / phaser-animated-tiles Goto Github PK
View Code? Open in Web Editor NEWA plugin that adds support for animated tiles to Phaser 3
Home Page: http://metroid.niklasberg.se/phaser-animated-tiles/
License: MIT License
A plugin that adds support for animated tiles to Phaser 3
Home Page: http://metroid.niklasberg.se/phaser-animated-tiles/
License: MIT License
After editing the map using the latest version of tiled, the plugin doesn't work
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.
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();
}
}
`
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
.
How can we get the original tile properties? The new one doesn't have the properties...
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.
If insertNull: true
in a map config, there will be TypeError: tile is null
error on animatedTiles.init(map)
Either it's repeated twice or the delaytime is doubled.
Hello,
would it be possible to animate sprites created from object layers by createFromObjects() as well, when the objects are based on animated tiles?
can I use this plugin for tilesprite ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.