Skip to content

samme/phaser-plugin-scene-watcher

Repository files navigation

Screenshot

Phaser 3 Scene Watcher Plugin

For each scene, it shows (left to right):

  1. key
  2. status
  3. display list count
  4. update list count
  5. active (a)
  6. visible (v)
  7. transitioning (t)
  8. input active (i)
  9. keyboard input active (k)

See the demo or Cavern Quest.

Browser / UMD

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser-plugin-scene-watcher.umd.js"></script>

Use the global PhaserSceneWatcherPlugin.

/* global PhaserSceneWatcherPlugin */

new Phaser.Game({
  plugins: {
    global: [
      { key: 'SceneWatcher', plugin: PhaserSceneWatcherPlugin, start: true }
    ]
  },
});

Module

Install phaser-plugin-scene-watcher from npm and use the default import:

import SceneWatcherPlugin from 'phaser-plugin-scene-watcher';

new Phaser.Game({
  plugins: {
    global: [
      { key: 'SceneWatcher', plugin: SceneWatcherPlugin, start: true }
    ]
  },
});

Quick load

function preload () {
  this.load.plugin('PhaserSceneWatcherPlugin', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser-plugin-scene-watcher.umd.js', true);
}

Log scene events to console

watchAll() starts logging scene events for all existing scenes. Call it once after all scenes are added.

From the game configuration:

new Phaser.Game({
  callbacks: {
    postBoot: function (game) {
      // Use the `key` you added the plugin with.
      game.plugins.get('SceneWatcher').watchAll();
    }
  }
});

From a scene:

function init () {
  // Use the `key` you added the plugin with.
  this.plugins.get('SceneWatcher').watchAll();
}