Skip to content
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

add example for changing animation display bone by name. #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 21 additions & 4 deletions tests/CocoStudioTest/ArmatureTest/ArmatureTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ var TestCSWithSkeleton = ArmatureTestLayer.extend({
armature.getAnimation().playByIndex(0);
armature.setScale(0.2);
armature.setAnchorPoint(cc.p(0.5, 0.5));
armature.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
armature.setPosition(cc.p(winSize.width / 3, winSize.height / 2));
this.addChild(armature);
},
title:function () {
Expand Down Expand Up @@ -376,6 +376,8 @@ var TestParticleDisplay = ArmatureTestLayer.extend({
var TestUseMutiplePicture = ArmatureTestLayer.extend({
displayIndex:0,
armature:null,
armature2:null,
weapon : null,
onEnter:function () {
this._super();
this.setTouchEnabled(true);
Expand All @@ -386,22 +388,35 @@ var TestUseMutiplePicture = ArmatureTestLayer.extend({

this.armature = ccs.Armature.create("Knight_f/Knight");
this.armature.getAnimation().playByIndex(0);
this.armature.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
this.armature.setPosition(cc.p(winSize.width / 3, winSize.height / 2));
this.armature.setScale(1.2);
this.addChild(this.armature);

var weapon = ["weapon_f-sword.png", "weapon_f-sword2.png", "weapon_f-sword3.png", "weapon_f-sword4.png", "weapon_f-sword5.png", "weapon_f-knife.png", "weapon_f-hammer.png"];
this.armature2 = ccs.Armature.create("Knight_f/Knight");
this.armature2.getAnimation().playByIndex(0);
this.armature2.setPosition(cc.p(2 * winSize.width / 3, winSize.height / 2));
this.armature2.setScale(1.2);
this.addChild(this.armature2);

this.weapon = ["weapon_f-sword.png", "weapon_f-sword2.png", "weapon_f-sword3.png", "weapon_f-sword4.png", "weapon_f-sword5.png", "weapon_f-knife.png", "weapon_f-hammer.png"];

//add skin
for (var i = 0; i < 7; i++) {
var skin = ccs.Skin.createWithSpriteFrameName(weapon[i]);
var skin = ccs.Skin.createWithSpriteFrameName(this.weapon[i]);
this.armature.getBone("weapon").addDisplay(skin, i);

var skin2 = ccs.Skin.createWithSpriteFrameName(this.weapon[i]);
this.armature2.getBone("weapon").addDisplay(skin2, i);
}

//add label
var label = cc.LabelTTF.create("This is a weapon!", "Arial", 18);
label.setAnchorPoint(cc.p(0.2, 0.5));
this.armature.getBone("weapon").addDisplay(label, 7);

var label2 = cc.LabelTTF.create("This is a weapon!", "Arial", 18);
label2.setAnchorPoint(cc.p(0.2, 0.5));
this.armature2.getBone("weapon").addDisplay(label2, 7);
},
title:function () {
return "Test One CCArmature Use Different Picture";
Expand All @@ -413,6 +428,8 @@ var TestUseMutiplePicture = ArmatureTestLayer.extend({
++this.displayIndex;
this.displayIndex = (this.displayIndex) % 8;
this.armature.getBone("weapon").changeDisplayByIndex(this.displayIndex, true);

this.armature2.getBone("weapon").changeDisplayByName(this.weapon[this.displayIndex], true);
return false;
}
});
Expand Down