SpineNode.cpp文件
#include "SpineNode.h"
#include "SpineUtils.h"using namespace cocos2d;
static Vector<Texture2D*>* _displayTexs = nullptr;
struct _Entry
{
int slotIndex;
const char* name;
spAttachment* attachment;
_Entry* next;
};
typedef struct
{
spSkin super;
_Entry* entries;
} _spSkin;
SpineNode::SpineNode(spSkeletonData* skeletonData)
: SkeletonAnimation(skeletonData)
{
}
SpineNode::SpineNode(const std::string& skeletonDataFile, spAtlas* atlas, float scale)
: SkeletonAnimation(skeletonDataFile, atlas, scale)
{
}
SpineNode::SpineNode(const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
: SkeletonAnimation(skeletonDataFile, atlasFile, scale)
{
}
SpineNode* SpineNode::createWithData(spSkeletonData* skeletonData)
{
SpineNode* node = new SpineNode(skeletonData);
node->autorelease();
return node;
}
SpineNode* SpineNode::createWithFile(const std::string& skeletonDataFile, spAtlas* atlas, float scale)
{
SpineNode* node = new SpineNode(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
SpineNode* SpineNode::createWithFile(const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
{
SpineNode* node = new SpineNode(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
bool SpineNode::isFlippedX() const
{
return _skeleton->flipX != 0;
}
void SpineNode::setFlippedX(bool flippedX)
{
_skeleton->flipX = flippedX ? 1 : 0;
}
bool SpineNode::isFlippedY() const
{
return _skeleton->flipY != 0;
}
void SpineNode::setFlippedY(bool flippedY)
{
_skeleton->flipY = flippedY ? 1 : 0;
}
bool SpineNode::replacementParts(const std::string& skinName, const std::string& attachmentName)
{
CCLOG("in replacementParts 0");
if (skinName.empty())
{
return false;
}
CCLOG("in replacementParts 1");
spSkin *skin = spSkeletonData_findSkin(_skeleton->data, skinName.c_str());
if (!skin) return false;
CCLOG("in replacementParts 2");
if (_skeleton->skin)
{
const _Entry *entry = reinterpret_cast<_spSkin *>(_sk