Skip to content

#1132: Improved _ctor implementation and added test for extending SkeletonAnimation #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frameworks/js-bindings/bindings/script/jsb_spine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand Down
9 changes: 8 additions & 1 deletion samples/js-tests/src/SpineTest/SpineTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ 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 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);
spineBoy.setMix('walk', 'jump', 0.2);
Expand Down