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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@b7az3/robowhale-phaser

v1.0.2

Published

Reusable Phaser 3 utilities and UI components

Downloads

375

Readme

@b7az3/robowhale-phaser

npm version Phaser 3 License: MIT

A collection of reusable, generic Phaser 3 utilities and UI components.
Designed to be dependency‑free (except Phaser itself), fully configurable, and well‑documented.


Table of Contents


GitHub Repo

https://github.com/B7AZ3/robowhale-phaser

Installation

npm install @b7az3/robowhale-phaser

Usage

Import components directly from the main entry or from subpaths (recommended for tree‑shaking):

// Main entry (exports everything)
import { SimpleButton, GridArray, BaseScene } from '@b7az3/robowhale-phaser';

// Deep imports – more granular
import SimpleButton from '@b7az3/robowhale-phaser/phaser3/gameObjects/buttons/SimpleButton.js';
import { Direction } from '@b7az3/robowhale-phaser/utils/Direction.js';

🚀 Quick Start

import { BaseScene, SimpleButton, GridArray, DeviceUtil } from '@b7az3/robowhale-phaser';

class MyScene extends BaseScene {
    create() {
        // Simple button with press feedback
        const btn = new SimpleButton(this, {
            texture: 'ui_atlas',
            frame: 'btn_blue',
            onPress: () => console.log('Clicked!')
        });
        this.add.existing(btn);
        
        // Grid storage
        const grid = new GridArray(5, 5);
        grid.addAt(2, 2, { name: 'player' });
        
        // Device detection
        if (DeviceUtil.isDesktop()) {
            console.log('Running on desktop');
        }
    }
}

📚 Modules Overview 🧩 Grid

GridArray – 2D grid data structure with neighbor queries, dynamic resizing, and iteration helpers.

🎮 Phaser 3 Extensions

Phaser3Extensions – Augments Phaser prototypes with extra methods (tween helpers, factory methods, scaling, etc.). Call Phaser3Extensions.polyfill() once.

KineticScroll – Inertial (kinetic) scrolling for cameras with touch/mouse wheel support.

RenderStatsDOM – Real‑time FPS / draw call overlay.

🔘 Buttons

SimpleButton – Basic image button with press tween and optional sound.

ComplexButton – Container‑based button with icon, text, and flexible layout.

ToggleButton – Two‑state button that swaps frames.

SoundButton / MusicButton – Specialised buttons for toggling sound/music mute (customisable callbacks).

SwitchButton – Left/right arrow selector with title and dynamic text.

🖼️ Containers & Screens

PhaserScreen – Full‑screen overlay with background and responsive pinning.

SwitchButton – See above.

📝 Text

AutosizeText – Automatically scales text to fit within a bounding box.

🍞 Toast Notifications

Toast – Popup message with auto‑dismiss.

ToastsManager – Manages a queue of toasts (extends PhaserScreen).

🌊 Particles

ParticleUtil – Helper methods for particle emission zones (texture‑based, circle edge, random values).

🎬 Scenes

BaseScene – Extended scene with pinning, scaling, fast‑forward, and keyboard shortcuts.

FastForward – Speeds up / slows down scene tweens and time.

Pinner – Pin objects to relative screen positions.

Scaler – Responsive scaling of game objects (fit, fill, cover).

💾 Storage

IdbKeyvalWrapper – IndexedDB wrapper (native, no external lib).

LocalStorageWrapper – Namespaced localStorage.

RuntimeStorage – In‑memory store.

🛠️ Utilities

Direction / getOrthoDirection – 8‑directional constants.

DeviceUtil – Desktop detection, device memory.

NetUtil – Host detection, iframe check.

parseMilliseconds, toMs – Time conversion.

updateUrlQuery – URL parameter manipulation.

isAvifSupported, isWebpSupported, isWebAssemblySupported – Feature detection.

cssAnimate – Promise‑based CSS animation helper.

🔧 Polyfills

Polyfills – Adds Element.remove() if missing.

🧪 Advanced Usage Examples Kinetic scrolling with bounds checking

import { KineticScroll } from '@b7az3/robowhale-phaser';

const scroller = new KineticScroll(this, {
    camera: this.cameras.main,
    horizontalScroll: true,
    verticalScroll: true,
    kineticMovement: true
});
scroller.addPointerListeners();
// In update() call scroller.update();

Autosize text inside a fixed rectangle

import { AutosizeText } from '@b7az3/robowhale-phaser';

const text = new AutosizeText(scene, 400, 300, 'Long text...', {
    fontFamily: 'Arial',
    fontSize: '32px',
    color: '#fff'
}, { maxWidth: 200, maxHeight: 100 });
scene.add.existing(text);

Using storage with fallback

import { IdbKeyvalWrapper, LocalStorageWrapper } from '@b7az3/robowhale-phaser';

let storage;
if (window.indexedDB) {
    storage = new IdbKeyvalWrapper('my_game');
    await storage.init();
} else {
    storage = new LocalStorageWrapper('my_game');
}
await storage.saveValue('score', 100);
const score = await storage.getNumber('score');

Creating a toggle button with custom callback

import { ToggleButton } from '@b7az3/robowhale-phaser';

const toggle = new ToggleButton(scene, {
    texture: 'ui_atlas',
    frameState1: 'sound_on',
    frameState2: 'sound_off',
    onStateChange: (state) => {
        console.log(state === 1 ? 'ON' : 'OFF');
    }
});

You can import sub‑modules directly to reduce bundle size:

import SimpleButton from '@b7az3/robowhale-phaser/phaser3/gameObjects/buttons/SimpleButton.js';

⚙️ Configuration & Extensibility

Most components accept a configuration object rather than many positional arguments. All callbacks (onPress, onRelease, onUpdate, etc.) are optional, and sound is only played if you provide sound.key.

To add your own global extensions, use the Phaser3Extensions class – you can cherry‑pick which extensions to apply. 🤝 Contributing

Contributions are welcome! Please follow the existing code style and add JSDoc for any new methods. 📄 License

MIT © b7az3