Hi Nate!
Using the c runtime, I can "unset" an attachement by calling
spSkeleton_setAttachment(_skeleton, "mySlotName", NULL);
But the c++ framework for cocos2dx does not allow this because the API uses std::string&
I see 2 possible solutions for this:
1/ Create a new API for c++ runtime :
bool removeAttachment(const std::string& slotName);
or
2/ Change the setAttachement code (SkeletonRenderer.cpp) from
bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) {
return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.c_str()) ? true : false;
}
to
bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) {
return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName == "" ? NULL : attachmentName.c_str()) ? true : false;
}
I do prefer the second option since it works more like the C API.
Thanks a lot,
Kiki
Oh and by the way, the same goes for
bool SkeletonRenderer::setSkin (const std::string& skinName)
which needs the same treatment (an empty string could remove the skin).
Thanks!
Kiki
Not sure if you saw my post Nate,
am I mistaken, or is there another way to remove an attachement using the c++ runtime?
I've locally patched the runtime to support the empty string as removal, but I'd prefer to be sure it's (or will be) the correct way to do that (it's working fine with the code I posted anyway).
Thanks,
Kiki