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-ui-components

v3.1.3

Published

phaser.io UI component library for use in browser games using the Phaser3 game engine

Downloads

55

Readme

phaser-ui-components

phaser.io UI component library for use in browser games using the Phaser3 game engine

Code Demo and UI Example: npmjs sandbox

UI Interactive Components

  • Text Button: a Phaser.GameObjects.Container that can contain a centre-aligned text string and a background with either rounded or square corners.
  • Card: an object that can contain a header, image, title, and description similar to a HTML card. the Card object is comprised of separate CardHeader, CardImage, and CardBody objects allowing for individual use as needed.
    • CardHeader: the card header can have a text value and a background which can include rounded upper corners. options for the header are similar to those for a TextButton as the two are nearly identical in looks with the main difference being that the CardHeader will only round the top corners if a non-zero cornerRadius is supplied in the CardHeaderOptions
    • CardImage: the card image can have a Phaser.GameObjects.Sprite image and a background. the sprite will be scaled to fill the specified width and height of the CardImage object while maintaining it's aspect ratio.
    • CardBody: the card body contains a title, description and area for buttons (all of which are optional). the button area makes use of a FlexLayout so buttons will wrap once they've filled the width available.

UI Layout Components

GridLayout

a UI layout that divides the screen area into rows and columns and provides control over the alignment and positioning of items placed within each GridCell of the GridLayout.

you must add content to each GridCell of the GridLayout by calling new GridLayout(scene).getGridCell(0, 0).setContent(new TextButton(scene, TextButtonOptions.primary({text: 'foo'}))) where getGridCell(0, 0) returns the top-left cell and getGridCell(0, 11) returns the top-right cell

LinearLayout

a UI layout that centre aligns all contents in either a horizontal or vertical orientataion based on the option specified (default is horizontal).

FlexLayout

a UI layout that places as many LayoutContent items on the same row as will fit based on the layout's width and padding before wrapping to the next row and continuing the process.

NOTE: Phaser.GameObjects.Graphics objects do not report their width properly so they should be placed inside a Phaser.GameObjects.Container who's size is set before being added to this layout for proper placement

UI Utilities

Colors module

provides functions to convert between hexidecimal strings and numbers as well as for determining if a colour is dark. also contains a set of predefined colours like Colors.primary, Colors.info, and Colors.danger and can generate random colours.

  • Colors.isDark(color: string | number): boolean - returns true if 50% or more of the colour's hexidecimal values are between 0 and 7
  • Colors.toHexString(color: number): string - converts a number like 0xfc5a6d to a string like #fc5a6d
  • Colors.toHexNumber(color: string): number - converts a string like #fc5a6d to a number like 0xfc5a6d
  • Colors.random(): string - generates a random colour string like #fc5a6d

Styles module

provides preset text and graphics styles that can be used with your UI components. for example: Styles.primary().text contains preset values for use as a Phaser.Types.GameObjects.Text.TextStyle object that will work well with a background of Styles.primary().graphics that contains preset values for use as a Phaser.Types.GameObjects.Graphics.Styles object