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

gamesprites

v1.1.0

Published

make spritesheets for use in games

Downloads

11

Readme

gamesprites

A Node.js script for creating spritesheets for use in games.

Currently it outputs layout/animation data suitable for using with CreateJS, though support for other engines could be added in the future.

Usage

After sprites = require('gamesprites'), call sprites.compile(dir, outname) where dir is a path to a directory of images to be packed into a spritesheet, and outname is where to save the output image and data, sans extension.

For example, sprites.compile("resources/sprites", "static/images/spritesheet") will pack all of the images in resources/sprites and output static/images/spritesheet.png and static/images/spritesheet.json.

Offsets, Framerates, Animations

The script will pack all valid images in the provided directory into a single texture atlas, and assign names to the animations based on the source images' filenames. If a filename ends with an underscore followed by a number, it'll truncate that and use the number as a cue for ordering within an animation. For example:

  • idle.png will generate a single-frame animation called "idle".
  • walk_0.png, walk_1.png, walk_2.png will generate a three-frame animation called "walk".

Other options can be set by adding a suffix to the filename followed by the options. The options are:

  • l, c, r: x-offset of the sprite. Left, center, right, respectively.
  • t, m, b: y-offset. Top, middle, bottom.
  • s: speed of the animation. (currently not implemented)
  • p: flag the animation as ping-pong. (currently not implemented)
  • d: duplicate this frame.(currently not implemented)

s and p affect the whole animation, but only need to be marked on the first frame of that animation.

For example:

  • idle__bc.png will generate a single frame with a registration point at the bottom-center of the sprite.
  • walk_0__s0.5cm.png, walk_1.png, walk_2.png will generate a three-frame animation with a registration point at the center/middle of each frame at half speed.

The frames will just be ordered by the frame number given. That is, x_0.png, x_3.png, x_5.png will generate a three-frame animation in that order; the "missing" frames 1, 2, and 4 won't break anything.