Skip to content

Commit

Permalink
Merge pull request #370 from ShengxiangChen/master
Browse files Browse the repository at this point in the history
spine for cocos2d-html5
  • Loading branch information
dingpinglv committed Apr 28, 2014
2 parents bf378c4 + 4b18e2d commit a41ee84
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/SpineTest/SpineTest.js
Expand Up @@ -46,30 +46,33 @@ SpineTestScene = TestScene.extend({
touchcount = 0;

SpineTest = BaseTestLayer.extend({
_spineboy:null,
ctor:function () {
this._super(cc.c4b(0,0,0,255), cc.c4b(98,99,117,255));

size = director.getWinSize();
var size = director.getWinSize();

/////////////////////////////
// Make Spine's Animated skeleton Node
// You need 'json + atlas + image' resource files to make it.
// No JS binding for spine-c in this version. So, only file loading is supported.
spineboy = sp.SkeletonAnimation.createWithFile('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
var spineboy = cc.SkeletonAnimation.createWithFile('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
spineboy.setPosition(cc.p(size.width / 2, size.height / 2 - 150));
spineboy.setAnimation(0, 'walk', true);
spineboy.setMix('walk', 'jump', 0.2);
spineboy.setMix('jump', 'walk', 0.4);
spineboy.setAnimationListener(this, this.animationStateEvent);
this.addChild(spineboy, 4);

this._spineboy = spineboy;
},
onBackCallback:function (sender) {
},
onRestartCallback:function (sender) {
},
onNextCallback:function (sender) {
touchcount++;
spineboy.setAnimation(0, ['walk', 'jump'][touchcount % 2], true);
this._spineboy.setAnimation(0, ['walk', 'jump'][touchcount % 2], true);
},
subtitle:function () {
return "Spine test";
Expand All @@ -79,7 +82,7 @@ SpineTest = BaseTestLayer.extend({
},

animationStateEvent: function(obj, trackIndex, type, event, loopCount) {
var entry = spineboy.getCurrent();
var entry = this._spineboy.getCurrent();
var animationName = (entry && entry.animation) ? entry.animation.name : 0;

switch(type)
Expand Down
1 change: 1 addition & 0 deletions tests/tests-boot-html5.js
Expand Up @@ -32,6 +32,7 @@
chipmunk:true,
showFPS:true,
loadExtension:true,
loadSpine:true,
frameRate:60,
renderMode:0, //Choose of RenderMode: 0(default), 1(Canvas only), 2(WebGL only)
tag:'gameCanvas', //the dom element to run cocos2d on
Expand Down
3 changes: 2 additions & 1 deletion tests/tests-main.js
Expand Up @@ -443,7 +443,8 @@ var testNames = [
},
{
title:"Spine Test",
platforms: PLATFORM_JSB,
resource: g_spine,
platforms: PLATFORM_ALL,
testScene:function () {
return new SpineTestScene();
}
Expand Down
7 changes: 7 additions & 0 deletions tests/tests_resources-html5.js
Expand Up @@ -810,4 +810,11 @@ var g_tilemaps = [
{src:"res/TileMaps/test-object-layer.tmx"},
{src:"res/TileMaps/ortho-tile-property.tmx"},
{src:"res/TileMaps/ortho-rotation-test.tmx"}
];


var g_spine = [
{src:"res/skeletons/spineboy.atlas"},
{src:"res/skeletons/spineboy.json"},
{src:"res/skeletons/spineboy.png"}
];

0 comments on commit a41ee84

Please sign in to comment.