• Runtimes
  • Attachment issue in cocos2d-x

  • تم التحرير
Related Discussions
...

Hi Community,

I am new to this tool.First i must thank to Spine community for giving such a good tool for implementing animations.In my game the player holds different arms(ex: sword, axe, hammer, bow) based on level to fight with enemy.I have to replace the arm based on type of selection. All these images are in same texture. I have tried using setAttachment() method for this. But its not working. After searching many tutorials, I came to know that we have to create new skin to do this thing instead of using default.

Please help me how to implement this in c++. Waiting for your replay.

Thanks

You don't need a skin if you are only changing a single attachment. However you will need to place all the images in the same slot and then you can use setAttachment on that slot to set which of the images are used.

Sets the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin,

http://esotericsoftware.com/spine-using ... s#Skeleton

2 أشهر لاحقا

Thanks for replay.Still i am facing the problem.
How i can replace images in a slot at run time?
I am using following lines of code.In this "slotName" and "attachmentName" parameters are there.

In spine example i tried by replacing different slot names which are taken from .json file.But it did not worked for me.
skeletonNode->setAttachment(slotName, attachmentName);
Can you please explain how to do it using spine example in cocos2d-X?Please help me.

شهر واحد لاحقا

Thanks for your help.
Actually i am using setAttachment() method with the same skin.
After reading docs I got to know the following point:
"When a new skin is set and the skeleton already has a skin, then attachments from the new skin are attached if an attachment with the same name in the old skin was attached. Otherwise, no attachments are changed."

So i did as follows:
skeletonNode->setSkin("skinName");
skeletonNode->setSlotsToSetupPose();
skeletonNode->setAttachment("slotName", "attachmentName");

It worked for me.Thanks