GithubHelp home page GithubHelp logo

isabella232 / pixi-spine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pixijs/spine

0.0 0.0 0.0 6.24 MB

Pixi.js plugin that enables Spine support.

License: Other

JavaScript 0.27% TypeScript 99.73%

pixi-spine's Introduction

pixi-spine

Spine 3.8 implementation for PixiJS v5.

Supports both json and skel formats.

PixiJS v5 Spine 3.8 - this branch, latest npm

PixiJS v5 Spine 3.7 - pixi5-spine3.7 branch npm 2.0.5

PixiJS v4 Spine 3.8 - pixi4-spine3.8 branch , no npm

PixiJS v4 Spine 3.7 - v4.x branch npm version 1.5.21

PixiJS v3 Spine 3.8 - pixi3-spine3.8 branch, no npm

Demos:

https://pixijs.io/examples/#/plugin-spine/spineboy-pro.js

https://pixijs.io/examples/#/plugin-projection/runner.js

https://sbfkcel.github.io/pixi-spine-debug/

Usage

Prebuilt Files

If you are just including the built files, pixi spine adds itself to a PIXI namespace:

new PIXI.spine.Spine();

Basic example

var app = new PIXI.Application();

document.body.appendChild(app.view);

app.loader
    .add('spineCharacter', 'spine-data-1/HERO.json')
    .load(function (loader, resources) {
        var animation = new PIXI.spine.Spine(resources.spineCharacter.spineData);

        // add the animation to the scene and render...
        app.stage.addChild(animation);
        
        // run 
        var animation = new PIXI.spine.Spine(spineBoyData);
        if (animation.state.hasAnimation('run')) {
            // run forever, little boy!
            animation.state.setAnimation(0, 'run', true);
            // dont run too fast
            animation.state.timeScale = 0.1;
        }
        
        app.start();
    });

Want to go advanced?

Read our docs.

Two-color tint

Light-dark tint is supported with help of pixi-heaven

let spine = new PIXI.heaven.Spine(spineData);

Debug

To show bones and bounds you can use pixi-spine-debug. If you want to write your own debug plugin, look at how this one was created

Demo: https://sbfkcel.github.io/pixi-spine-debug/

WebPack and Angular

Possible webpack way:

import * as PIXI from "pixi.js';
window.PIXI = PIXI;
import "pixi-spine";

Angular:

import * as PIXI from "pixi.js";
global.PIXI = PIXI;
require("pixi-spine");

Using webpack or browserify?

Our library is tested for integration with webpack and browserify, check our travis config and checkpack.

How to get a wrong result using browserify/webpack

If resource.spineData is missing and you consider to use resource.data instead, please don't do that and think about middlewares. You probably created loader before pixi-spine was connected to the project. Consider that you use app.loader, here's what to check:

if (app.loader._afterMiddleware.indexOf(PIXI.spine.AtlasParser.use) < 0) {
   app.loader.use(PIXI.spine.AtlasParser.use);
   console.log('Hey, I managed to initialize loader before pixi-spine module!');
}

If you see it in the console, then you should consider using pixi.js and pixi-spine as external dependencies and not pack them inside the build. Or at least create loader in the same module you call add and load functions.

Typescript

There's "bin/pixi-spine.d.ts" file, you can use it.

Spine version

We aim to support the latest stable version of spine.

If you are below Spine 3.5, please please enable "beta updates" and re-export everything from the spine editor.

According to spine runtime license, you can use runtime only if you have bought the editor, so exporting latest versions of animations shouldn't be a problem for you.

Building

You will need to have node setup on your machine.

Make sure you have yarn installed:

npm install -g yarn

Then you can install dependencies and build:

yarn
yarn build

That will output the built distributables to ./bin.

pixi-spine's People

Contributors

abhishekrathore03 avatar alebles avatar alemoroz avatar congtung10t2 avatar cursedcoder avatar djmisterjon avatar elizavetta avatar englercj avatar exponenta avatar gatsinski avatar goodboydigital avatar greenishflow avatar gurmukhp avatar ivanpopelyshev avatar jmlee2k avatar johanlajili avatar kieirra avatar knifhen avatar krzysztof-o avatar lloydevans avatar magikarp-2020 avatar mattostgard avatar patrick-hammond avatar pawelstan avatar probityrules avatar qwertykg avatar rblstr avatar simontadram avatar themoonrat avatar zprodev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.