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 🙏

© 2025 – Pkg Stats / Ryan Hefner

phaser-tile-animator

v1.0.5

Published

A lightweight Phaser 3 plugin for animating Tiled tilesets directly in-game

Downloads

539

Readme

🪄 phaser-tile-animator

🧱 A lightweight, dependency-free Phaser 3 plugin that animates Tiled tilesets directly inside your game — no need for custom frame logic or sprite hacks.


🚀 Features

  • 🎨 Supports Tiled animated tiles out of the box (tileData.animation in exported JSON)
  • Optimized — updates only the tiles that actually animate (no per-frame scans)
  • 🕹️ Easy API — just call this.tileAnimator.init(map)
  • ⏯️ pause() / resume() / destroy() built-in
  • 🧩 Works as a Scene Plugin — automatically integrates with Phaser’s lifecycle
  • 🧠 Written in TypeScript — ships with full type definitions

📦 Installation

npm install phaser-tile-animator

You must already have Phaser 3 installed:

npm install phaser

🧰 Setup

Add the plugin to your Phaser game configuration:

import { TileAnimatorPlugin } from 'phaser-tile-animator'

const config: Phaser.Types.Core.GameConfig = {
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  scene: [GameScene],
  plugins: {
    scene: [
      {
        key: 'TileAnimatorPlugin',
        plugin: TileAnimatorPlugin,
        mapping: 'tileAnimator' // accessible via this.tileAnimator
      }
    ]
  }
}

export default new Phaser.Game(config)

🎮 Usage

In your scene:

export class GameScene extends Phaser.Scene {
  create() {
    const map = this.make.tilemap({ key: 'map' })
    const tileset = map.addTilesetImage('beach', 'beach')
    map.createLayer('Ground', tileset, 0, 0)

    // 🎞️ Start tile animations
    this.tileAnimator.init(map)
    
    // 🎚️ Set animation framerate (default is 10 FPS)
    this.tileAnimator.setFrameRate(30) // 30 FPS for smooth animations
  }

  update() {
    // You can pause/resume animations anytime:
    this.tileAnimator.pause()
    this.tileAnimator.resume()
    
    // Or adjust framerate dynamically:
     this.tileAnimator.setFrameRate(60) // Speed up to 60 FPS
     this.tileAnimator.setFrameRate(5)  // Slow down to 5 FPS
  }
}

⚙️ API

| Method | Description | | ------------------------------------ | ------------------------------------------------------- | | init(map: Phaser.Tilemaps.Tilemap) | Reads Tiled animation data and starts animating tiles. | | pause() | Temporarily freezes all tile animations. | | resume() | Resumes paused animations. | | setFrameRate(fps: number) | Sets the absolute framerate for all animations (e.g., 10, 30, 60 FPS). | | getFrameRate() | Gets the current framerate in FPS. | | destroy() | Stops listening to scene updates and clears references. |


⚡ How It Works

TileAnimator reads tileData from each tileset (as exported by Tiled) and caches references to all tiles that need animation. Each frame, it updates only those tiles based on the durations defined in your .json map.

Performance: even large maps with hundreds of tiles animate smoothly, since each tile’s position is pre-cached at startup.


🧪 Example Tiled JSON snippet

"tileData" : {
  "8": {
    "animation": [
      { "duration": 350, "tileid": 8 },
      { "duration": 350, "tileid": 12 },
      { "duration": 350, "tileid": 16 }
    ]
  }
}

🧠 Tips

  • Works best with embedded tilesets in your map JSON (via Map → Embed Tilesets in Tiled).
  • Supports multiple tilesets automatically.
  • Use pause() when showing menus or paused screens.
  • Combine with global shaders or lighting for cool water/fire effects.

🧩 TypeScript Support

Full typings are included out of the box.

import { TileAnimator, TileAnimatorPlugin } from 'phaser-tile-animator'

📜 License

MIT © 2025 Matteo Franchini Made with ❤️ for the Phaser community.


🌟 Support

If you like the plugin, consider starring it on GitHub — it helps others discover it too!