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

phaser3-analog-counter

v1.0.0

Published

Class to use with Phaser 3 to show numbers in an analog counter display

Downloads

3

Readme

GitHub tag (latest by date) GitHub license

Phaser3-analog-counter

Class to use with Phaser 3 to show numbers in a "realistic" analog counter display.
Try demo here: https://jjcapellan.github.io/phaser3-analog-counter/

Table of contents

Installation

Browser

There are two alternatives:

  • Point a script tag to the CDN link:
<script src="https://cdn.jsdelivr.net/gh/jjcapellan/phaser3-analog-counter/dist/analog-counter.umd.js">
<script src="localPath/analog-counter.umd.js">

Then you can access the class by the global ShapeRec:

// In your create function ...
const myCounter = new AnalogCounter(this, x, y); 

From NPM

npm install phaser3-analog-counter

Then you can acces the class as:

  • CommonJS module
const AnalogCounter = require('phaser3-analog-counter');

// In your create function ...
const myCounter = new AnalogCounter(this, x, y); 
  • ES6 module
import AnalogCounter from 'phaser3-analog-counter';

// In your create function ...
const myCounter = new AnalogCounter(this, x, y);

Usage

This is the most simple use (all options by default):

// In your scene create function ...

// Constructor only needs 3 params: (scene, x , y)
const myCounter = new AnalogCounter(this, 100, 100);

myCounter.setNumber(89091);

The result using all default options is:

We can change some options:

const config = {
    digits: 3,
    backgroundColor: 0xcc0000,
    fontColor: '#ffffff'
}
const myCounter = new AnalogCounter(this, 100, 100, config);
myCounter.setNumber(243);

This is the result:

To change position and object origin:

const myCounter = new AnalogCounter(this, 100, 100);

// Same like in Phaser
myCounter.setOrigin(0.5);

// Changes position to {x:150, y:200}
myCounter.setPosition(150,200);

Options

This is the config object with all options:

interface CounterConfig {
    /**
     * Width of counter in pixels. Default: digits * (fontSize + 4)
     */
    width?: number,

    /**
     * Height of counter in pixels. Default: fontSize * 2 (max value)
     */
    height?: number,

    /**
     * Number of digits of counter. Default: 6
     */
    digits?: number,

    /**
     * Vertical space between digits in pixels. Default: fontSize/2
     */
    padding?: number,

    /**
     * CSS property "fontSize" of the font used to make the digits. Default: 24
     */
    fontSize?: number,

    /**
     * Color of font in html format (example: '#ff00ff'). Default: '#000000'
     */
    fontColor?: string,

    /**
     * Color of background in hex format (example: 0xff00ff). Default: 0xffffff
     */
    backgroundColor?: number,

    /**
     * Alpha value of shade effect. 0 disables this effect. Default 0.9.
     */
    shade?: number,
    
    /**
     * Time interval in milliseconds until reach a number. Default: 1000.
     */
    duration?: number;
}

License

This code is released under MIT LICENSE.