From 1f5c121aaa367ee79811d6c90c8d18d238af38e7 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 5 Feb 2015 12:45:35 +0800 Subject: [PATCH 1/2] #1132: Improved `_ctor` implementation and added test for extending SkeletonAnimation --- frameworks/js-bindings/bindings/script/jsb_spine.js | 8 ++++++-- samples/js-tests/src/SpineTest/SpineTest.js | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frameworks/js-bindings/bindings/script/jsb_spine.js b/frameworks/js-bindings/bindings/script/jsb_spine.js index f8d48d1f12..cb6e4acf57 100644 --- a/frameworks/js-bindings/bindings/script/jsb_spine.js +++ b/frameworks/js-bindings/bindings/script/jsb_spine.js @@ -22,8 +22,12 @@ sp.SkeletonAnimation.prototype._ctor = function(skeletonDataFile, atlasFile, scale) { if(atlasFile) { - this.initWithFile(skeletonDataFile, atlasFile, scale); - this.initialize(); + if (isNaN(scale)) { + scale = 1; + } + + this.initWithFile(skeletonDataFile, atlasFile, scale); + this.initialize(); } }; diff --git a/samples/js-tests/src/SpineTest/SpineTest.js b/samples/js-tests/src/SpineTest/SpineTest.js index 8d47e49894..d87a9fe6b3 100644 --- a/samples/js-tests/src/SpineTest/SpineTest.js +++ b/samples/js-tests/src/SpineTest/SpineTest.js @@ -43,6 +43,13 @@ SpineTestScene = TestScene.extend({ } }); +var SpineBoyAnimation = sp.SkeletonAnimation.extend({ + ctor: function() { + this._super('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + cc.log("Extended SkeletonAnimation"); + } +}); + touchcount = 0; var SpineTest = BaseTestLayer.extend({ @@ -82,7 +89,7 @@ var SpineTest = BaseTestLayer.extend({ // 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. - var spineBoy = sp.SkeletonAnimation.create('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + var spineBoy = new SpineBoyAnimation(); spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); spineBoy.setAnimation(0, 'walk', true); spineBoy.setMix('walk', 'jump', 0.2); From 88fa3cedc94aab328a9a60efd821829d04a2fc88 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 5 Feb 2015 12:59:06 +0800 Subject: [PATCH 2/2] #1132: Improve spine test case --- samples/js-tests/src/SpineTest/SpineTest.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/js-tests/src/SpineTest/SpineTest.js b/samples/js-tests/src/SpineTest/SpineTest.js index d87a9fe6b3..11e47c05c0 100644 --- a/samples/js-tests/src/SpineTest/SpineTest.js +++ b/samples/js-tests/src/SpineTest/SpineTest.js @@ -43,13 +43,6 @@ SpineTestScene = TestScene.extend({ } }); -var SpineBoyAnimation = sp.SkeletonAnimation.extend({ - ctor: function() { - this._super('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); - cc.log("Extended SkeletonAnimation"); - } -}); - touchcount = 0; var SpineTest = BaseTestLayer.extend({ @@ -89,6 +82,13 @@ var SpineTest = BaseTestLayer.extend({ // 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. + var SpineBoyAnimation = sp.SkeletonAnimation.extend({ + ctor: function() { + this._super('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + cc.log("Extended SkeletonAnimation"); + } + }); + var spineBoy = new SpineBoyAnimation(); spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); spineBoy.setAnimation(0, 'walk', true);