Can't use spine for pixi.js

2.2k Views Asked by At

I have already made spine project with animations and have already installed pixi in my web application, but can't use spine.

I have .atlas file, .json file and Sprite image.

This is my code:

var renderer = PIXI.autoDetectRenderer(800, 600);
jQuery("body").prepend(renderer.view);

// create the root of the scene graph
var stage = new PIXI.Container();

// load spine data
PIXI.loader
    .add('boy', 'assets/data/boy.json')
    .load(onAssetsLoaded);

var boy = null;

function onAssetsLoaded(loader,res)
{
    // instantiate the spine animation
    boy = new PIXI.spine.Spine(res.boy.spineData);
}

This causes console error: Cannot read property 'Spine' of undefined

As I understand, I have to add pixi-spine plugin, I couldn't understand how.

I am very beginner, please help

2

There are 2 best solutions below

0
On

You need to include the Pixi-spine Plugin, available at https://raw.githubusercontent.com/pixijs/pixi-spine/master/bin/pixi-spine.js.

0
On

Do you have pixi-spine.min.js added in your HTML like you do have pixi.min.js ?