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

@reltdeats/spine-phaser-ce

v0.9.7

Published

Spine runtimes plugin for Phaser CE.

Downloads

10

Readme

spine-phaser-ce

Spine runtimes plugin for Phaser CE. Check out the repository at github

Features

  • Full support of the last Spine version (4.x.x).
  • Support for Canvas and WebGL.
  • Support for Canvas mesh.

Requisites

  • Phaser CE 2.20.0 or newer (not tested with older versions).
  • Globally declared Phaser so the plugin can extend it.
  • Some spines to use with the plugin.

How to use

  1. Install via npm: npm install @reltdeats/spine-phaser-ce
  2. Add the plugin to your Phaser CE game:
import SpinePlugin from '@reltdeats/spine-phaser-ce';

this.game.plugins.add(SpinePlugin);

or...

  1. Use jsdelivr cdn:
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/@reltdeats/[email protected]/dist/spine-phaser-ce.min.js"></script>

this.game.plugins.add(SpinePlugin);
  1. Import the plugin:
this.game.plugins.add(SpinePlugin);
  1. Import your assets with the spine loader:
// The loader expects a config object with the following structure:
const spineDino = {
    image: require('../../assets/spines/dino.png'),
    atlas: require('../../assets/spines/dino.atlas'),
    json: require('../../assets/spines/dino.json')
}

// For spines with multiples atlases, 
// use images in plural and the key of 
// the image atlas must be the name of the atlas.
const spineBomb = {
    images: {
        Bomb: require('../../assets/spines/bomb/Bomb.png'),
        Bomb_2: require('../../assets/spines/bomb/Bomb_2.png')
    },
    atlas: require('../../assets/spines/bomb/Bomb.atlas.txt'),
    json: require('../../assets/spines/bomb/Bomb.json')
}

// Also, the loader supports binary format
const spineStar = {
    image: require('../../assets/spines/star/Star.png'),
    atlas: require('../../assets/spines/star/Star.atlas'),
    binary: require('../../assets/spines/star/Star.skel')
}
   
// Load the spine with your game loader
this.game.load.spine('spineStar', spineStar);
  1. Add the spine to the game:
// The last two arguments, group and premultipliedAlpha
// are optional. 
// Group is a reference to a Phaser.Group
this.star = this.game.add.spine(200, 300, 'spineStar', group, false);

Manipulating the Spine and examples

All transforms are handled by the Phaser CE system:

this.star.x = 300;
this.star.y = 100;
this.star.scale.setTo(1, 2);
this.star.scale.x = -1;
this.star.rotation = Phaser.Math.degToRad(45);

Specific Spine functionalities are handled by the oficial Spine runtimes. For handling animations, mixing and all the spine features, please refer to the oficial spine documentation.

Example:

this.star.animationState.setAnimation(0, 'Idle', true);

this.game.time.events.loop(8000, () => {
    this.star.animationState.setAnimation(0, 'In', false);
    this.star.animationState.addAnimation(0, 'Idle', false);
    this.star.animationState.addAnimation(0, 'Out', false);
});

For more examples, check out the example index.

If you are cloning the github repository, run the following commands to launch the examples in your web browser:

npm i
npm run serve

Debug

Debug is still in progress and shows little to no information. WIP.

To enable debug, just set the debug property of the spine to true.

this.star = this.game.add.spine(200, 300, 'spineStar', group, false);
this.star.debug = true;

Canvas mesh

To enable canvas mesh, set the enableCanvasMesh property of the spine to true.

Be aware, that canvas mesh is a hack to render each triangle of the mesh separately. This can cause some aliasing (cause the triangles are not attached to each other) and performance issues.

this.star = this.game.add.spine(200, 300, 'spineStar', group, false);
this.star.enableCanvasMesh = true;

Maintenance

I use this plugin in my daily work, so expect some improvements and inclusion of Phaser features over time.

Feel free to report any bugs the usual way in the github issues page.