npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

phaser-animated-tiles-phaser3.5

v2.0.5

Published

Phaser 3 Animated Tiles Plugin

Downloads

422

Readme

Phaser 3 Animated Tiles Plugin (Phaser 3.5+)

This is a fork from https://www.npmjs.com/package/phaser-animated-tiles that's unmaintained and not working with Phaser 3.5+

Usage

In your game scene, import the plugin:

import AnimatedTiles from 'phaser-animated-tiles-phaser3.5/dist/AnimatedTiles.min.js';

then add a preload function:

  preload() {
    this.load.scenePlugin('animatedTiles', AnimatedTiles, 'animatedTiles', 'animatedTiles');
  }

finally, create your tilemap and then reference it:

    this.sys.animatedTiles.init(this.map.tilemap);

ps: replace this.map.tilemap with your loaded tilemap.

Fix

This plugin also fixes an issue where null tiles were causing it to crash.

Credits

All credits to the respective plugin owner. I just fixed what was not being maintained anymore

Original documentation

A simple plugin with a simple purpose: to add support for animated tiles to Phaser 3 (3.8.0+) as exported from Tiled.

The bundled example is available live here: http://metroid.niklasberg.se/phaser-animated-tiles/

The plugin is also used in this platformer example: https://github.com/nkholski/phaser3-es6-webpack

The plugin is based on Photonstorms plugin template: https://github.com/photonstorm/phaser3-plugin-template

Latest build can be found in the dist folder or NPM: https://www.npmjs.com/package/phaser-animated-tiles

Run npm install and then npm run build to build the plugin.

Features

This plugin supports unlimited maps, layers and tilesets simultaneously. There are methods to control animations globally, within specified tilemaps or layers. Those methods can control such things as playback-rate both for all tiles and for specified tiles. ATM it's up to you to keep track on indicies for maps you add and their layers. For most cases that shouldn't be a problem. If you just want to support animated tiles exactly as specified in Tiled you need three lines; one to preload the plugin, one to register it in your create method and one to initilize it for your map.

Future

I have a few stuff I would like to add, of which some might be YAGNI:

  1. PutTile as the native API but will push the tile to the update list for that tile gid. If you put a tile over an animated tile, that tile should instead be removed from the list. The latter is just needed if the new gid is a part of the current anim, but still nice to have.
  2. Define animations programmatically.
  3. And if 2 is done: Allow animated rotation (probably 45 degree steps only), flipping and alpha. Tint? Stuff that Phaser supports.
  4. Method to reset everything to their first frame.

Install repository

Clone the repository from git and run npm i and you're set to go.

Demo / Dev

The plugin is bundled with a demo which is also used for testing during development. npm run demo or npm run dev

Build plugin

Build the plugin including minified version: npm run build

How to use the plugin

1. Load the plugin

Please check out these Phaser 3 demos http://labs.phaser.io/index.html?dir=plugins/&q= for various methods to load the plugin as a scene plugin.

2. Use the plugin API

To initilize the plugin you just need to pass the tilemap you want to animate to the plugin. The plugin requires a dynamic layers to work.

function create ()
{
    this.sys.animatedTiles.init(map);
}

This is actually all you need to do but you may control the plugin calling methods with "this.sys.animatedTiles.methodName()". (The inconsistency between passing a tilemap and a mapindex will be solved by excepting both in all concerned methods. Methods to find tilemaps, layers and tiles will be added.)

Current list of methods:

| Method | Args | Usage | | ------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | resetRates | mapIndex?: int | Sets playback rate to 1 globally and for each individual tile, pass mapIndex to limit the method to that map | | setRate | rate: int, gid?: int, map?: Phaser.Tilemap | Sets playback multiplier to 'rate'. A rate of 2 will play the animation twice as fast as configured in Tiled, and 0.5 half as fast. If a gid is specified the rate is exclusively set for that tile. If the global rate is set to 0.5 and the rate of a tile is set to 2 it will play as configured in Tiled (0.5*2 = 1). Pass tilemap to limit the method to that map. | | resume | layerIndex?:int, mapIndex?:int | Resume tile animations globally if no layerIndex is set (may be overridden by layers), otherwise for that layer only. Pass mapIndex to limit the method to that map. | | pause | layerIndex?:int, mapIndex?:int | Resume tile animations globally if no layerIndex is set and overrides layer settingsm, otherwise for that layer only. Pass mapIndex to limit the method to that map. | | updateAnimatedTiles | TODO | Tell the plugin when you have added new animated tiles to layers after initialization. Needed to detect new animations. |