Skip to content

Commit 1f5c121

Browse files
committed
cocos2d#1132: Improved _ctor implementation and added test for extending SkeletonAnimation
1 parent b174d31 commit 1f5c121

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

frameworks/js-bindings/bindings/script/jsb_spine.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222

2323
sp.SkeletonAnimation.prototype._ctor = function(skeletonDataFile, atlasFile, scale) {
2424
if(atlasFile) {
25-
this.initWithFile(skeletonDataFile, atlasFile, scale);
26-
this.initialize();
25+
if (isNaN(scale)) {
26+
scale = 1;
27+
}
28+
29+
this.initWithFile(skeletonDataFile, atlasFile, scale);
30+
this.initialize();
2731
}
2832
};
2933

samples/js-tests/src/SpineTest/SpineTest.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ SpineTestScene = TestScene.extend({
4343
}
4444
});
4545

46+
var SpineBoyAnimation = sp.SkeletonAnimation.extend({
47+
ctor: function() {
48+
this._super('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
49+
cc.log("Extended SkeletonAnimation");
50+
}
51+
});
52+
4653
touchcount = 0;
4754

4855
var SpineTest = BaseTestLayer.extend({
@@ -82,7 +89,7 @@ var SpineTest = BaseTestLayer.extend({
8289
// Make Spine's Animated skeleton Node
8390
// You need 'json + atlas + image' resource files to make it.
8491
// No JS binding for spine-c in this version. So, only file loading is supported.
85-
var spineBoy = sp.SkeletonAnimation.create('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
92+
var spineBoy = new SpineBoyAnimation();
8693
spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150));
8794
spineBoy.setAnimation(0, 'walk', true);
8895
spineBoy.setMix('walk', 'jump', 0.2);

0 commit comments

Comments
 (0)