brrreak

Was wondering if anybody knows how to check an attachment for a specific string value. I'm using Cocos2d and having a bit of trouble implementing a particular animation based on the value of an attachment on a slot. Using the goblin example:
if (left hand item == "Spear") {
[goblin setAnimation:@"attackSpear" withDelay:0];
} else {
[goblin setAnimation:@"attackDagger" withDelay:0];
}
Does anybody know how to do this? Doesn't have to be in Objective C, although it would be awesome if it was :D
brrreak
  • Mesajlar: 2

Duré

Are you just looking for the name of the attachment that you gave it in Spine? If so you can do:
Slot slot = mySkeleton.FindSlot("SlotNameInSpine");
if (slot.Attachment.Name == "Spear")
{
// your code here
}


Sorry it's not in objective-c :). Never programmed in it. Just make sure to check if the slot and the attachment are null or you'll get an exception.
Duré
  • Mesajlar: 42

brrreak

Thanks for the reply Duré! Sounds like that might fix my problem, will give it a shot later and post back here.

Edit: And it did! :clap: Here's the (ObjC) code:
Slot* _slot = [mySkeleton findSlot:@"left hand item"];
if (strcmp(_slot->attachment->name, "dagger")==0) {
[mySkeleton setAnimation:@"attackDagger" loop:NO];
} else {
[mySkeleton setAnimation:@"attackSpear" loop:NO];
}
Hope it helps somebody else. :)
brrreak
  • Mesajlar: 2


Dön Runtimes