Skip to content

Commit

Permalink
IT WORKS
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpopelyshev committed Sep 29, 2016
1 parent c582d34 commit 658f869
Show file tree
Hide file tree
Showing 30 changed files with 3,031 additions and 834 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ npm-debug.log
node_modules
dist
gh-pages
build-es6
63 changes: 42 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# pixi-spine

Spine implementation for pixi v3
Spine implementation for pixi v4

## Usage

### Browserify

If you use browserify you can use pixi-spine like this:
IMPORTANT! Following functions were renamed in pixi-spine 1.1.0:

```js
var PIXI = require('pixi.js'),
spine = require('pixi-spine');
Atlas to TextureAtlas
SkeletonJsonParser to SkeletonJson

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

// add the animation to the scene and render...
});
addAnimation to addAnimationWith
addAnimationByName to addAnimation
hasAnimationByName to hasAnimation
```

## Usage

### Prebuilt Files

If you are just including the built files, pixi spine adds itself to a pixi namespace:
Expand All @@ -35,14 +32,38 @@ PIXI.loader
});
```

### Typescript

Either you add pixi-spine as npm dependency, either as a prebuilt with definition file from "build-es5" folder

```ts
declare module PIXI {
declare module spine {
import * as sp from 'pixi-spine';
export = sp;
}
}
```

### How to use spine events

```js
// animation is the instantiated pixi-spine object
This is stupid, I know, that's java port, I'll fix this later. If you dont specify at least one function, it'll crash.

animation.state.onEvent = function(i, event) {
console.log('event fired!', i, event);
};
```js
animation.state.addListener({
/** Invoked when the current animation triggers an event. */
event : function(trackIndex, event) { alert('event fired '+event.data) }

/** Invoked when the current animation has completed.
* @param loopCount The number of times the animation reached the end. */
complete : function(trackIndex, loopCount) {}

/** Invoked just after the current animation is set. */
start: function (trackIndex) {}

/** Invoked just before the current animation is replaced. */
end: function (trackIndex) {}
})
```

### How to choose resolution
Expand Down Expand Up @@ -119,9 +140,9 @@ PIXI.loader

```js
var spineBoy = new PIXI.spine.Spine(spineBoyData);
if (spineBoy.state.hasAnimationByName('run')) {
if (spineBoy.state.hasAnimation('run')) {
//run forever, little boy!
spineBoy.state.setAnimationByName(0, 'run', true);
spineBoy.state.setAnimation(0, 'run', true);
//dont run too fast
spineBoy.state.timeScale = 0.1;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixi-spine",
"version": "1.0.28",
"version": "1.1.0",
"description": "Spine implementation for pixi v^3 and v^4",
"author": "Mat Groves",
"contributors": [
Expand Down
Loading

0 comments on commit 658f869

Please sign in to comment.