mirror of https://github.com/axmolengine/axmol.git
Removes CC prefix for CCSkeleton and CCSkeletonAnimation. Adds namespace `sp` for JSBindings.
This commit is contained in:
parent
30eb05b600
commit
538da31773
|
@ -40,25 +40,25 @@ using std::max;
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) {
|
Skeleton* Skeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonData, isOwnsSkeletonData);
|
Skeleton* node = new Skeleton(skeletonData, isOwnsSkeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
Skeleton* node = new Skeleton(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
|
Skeleton* node = new Skeleton(skeletonDataFile, atlasFile, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::initialize () {
|
void Skeleton::initialize () {
|
||||||
atlas = 0;
|
atlas = 0;
|
||||||
debugSlots = false;
|
debugSlots = false;
|
||||||
debugBones = false;
|
debugBones = false;
|
||||||
|
@ -73,23 +73,23 @@ void CCSkeleton::initialize () {
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
skeleton = spSkeleton_create(skeletonData);
|
skeleton = spSkeleton_create(skeletonData);
|
||||||
rootBone = skeleton->bones[0];
|
rootBone = skeleton->bones[0];
|
||||||
this->ownsSkeletonData = isOwnsSkeletonData;
|
this->ownsSkeletonData = isOwnsSkeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton () {
|
Skeleton::Skeleton () {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
Skeleton::Skeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) {
|
Skeleton::Skeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
spSkeletonJson* json = spSkeletonJson_create(aAtlas);
|
spSkeletonJson* json = spSkeletonJson_create(aAtlas);
|
||||||
|
@ -101,7 +101,7 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float sca
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
Skeleton::Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
atlas = spAtlas_readAtlasFile(atlasFile);
|
atlas = spAtlas_readAtlasFile(atlasFile);
|
||||||
|
@ -116,17 +116,17 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, flo
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::~CCSkeleton () {
|
Skeleton::~Skeleton () {
|
||||||
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
|
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
|
||||||
if (atlas) spAtlas_dispose(atlas);
|
if (atlas) spAtlas_dispose(atlas);
|
||||||
spSkeleton_dispose(skeleton);
|
spSkeleton_dispose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::update (float deltaTime) {
|
void Skeleton::update (float deltaTime) {
|
||||||
spSkeleton_update(skeleton, deltaTime * timeScale);
|
spSkeleton_update(skeleton, deltaTime * timeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::draw () {
|
void Skeleton::draw () {
|
||||||
CC_NODE_DRAW_SETUP();
|
CC_NODE_DRAW_SETUP();
|
||||||
|
|
||||||
GL::blendFunc(blendFunc.src, blendFunc.dst);
|
GL::blendFunc(blendFunc.src, blendFunc.dst);
|
||||||
|
@ -222,11 +222,11 @@ void CCSkeleton::draw () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureAtlas* CCSkeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const {
|
TextureAtlas* Skeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const {
|
||||||
return (TextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
return (TextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect CCSkeleton::getBoundingBox () const {
|
Rect Skeleton::getBoundingBox () const {
|
||||||
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
||||||
float scaleX = getScaleX();
|
float scaleX = getScaleX();
|
||||||
float scaleY = getScaleY();
|
float scaleY = getScaleY();
|
||||||
|
@ -259,50 +259,50 @@ Rect CCSkeleton::getBoundingBox () const {
|
||||||
|
|
||||||
// --- Convenience methods for Skeleton_* functions.
|
// --- Convenience methods for Skeleton_* functions.
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void Skeleton::updateWorldTransform () {
|
||||||
spSkeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setToSetupPose () {
|
void Skeleton::setToSetupPose () {
|
||||||
spSkeleton_setToSetupPose(skeleton);
|
spSkeleton_setToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setBonesToSetupPose () {
|
void Skeleton::setBonesToSetupPose () {
|
||||||
spSkeleton_setBonesToSetupPose(skeleton);
|
spSkeleton_setBonesToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setSlotsToSetupPose () {
|
void Skeleton::setSlotsToSetupPose () {
|
||||||
spSkeleton_setSlotsToSetupPose(skeleton);
|
spSkeleton_setSlotsToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
spBone* CCSkeleton::findBone (const char* boneName) const {
|
spBone* Skeleton::findBone (const char* boneName) const {
|
||||||
return spSkeleton_findBone(skeleton, boneName);
|
return spSkeleton_findBone(skeleton, boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
spSlot* CCSkeleton::findSlot (const char* slotName) const {
|
spSlot* Skeleton::findSlot (const char* slotName) const {
|
||||||
return spSkeleton_findSlot(skeleton, slotName);
|
return spSkeleton_findSlot(skeleton, slotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCSkeleton::setSkin (const char* skinName) {
|
bool Skeleton::setSkin (const char* skinName) {
|
||||||
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
|
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAttachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
spAttachment* Skeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
||||||
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
||||||
}
|
}
|
||||||
bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
bool Skeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
||||||
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CCBlendProtocol
|
// --- CCBlendProtocol
|
||||||
|
|
||||||
const cocos2d::BlendFunc& CCSkeleton::getBlendFunc () const {
|
const cocos2d::BlendFunc& Skeleton::getBlendFunc () const {
|
||||||
return blendFunc;
|
return blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) {
|
void Skeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) {
|
||||||
this->blendFunc = aBlendFunc;
|
this->blendFunc = aBlendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture)
|
void Skeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture)
|
||||||
{
|
{
|
||||||
if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha())
|
if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha())
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace spine {
|
||||||
/**
|
/**
|
||||||
Draws a skeleton.
|
Draws a skeleton.
|
||||||
*/
|
*/
|
||||||
class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
class Skeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
||||||
public:
|
public:
|
||||||
spSkeleton* skeleton;
|
spSkeleton* skeleton;
|
||||||
spBone* rootBone;
|
spBone* rootBone;
|
||||||
|
@ -52,15 +52,15 @@ public:
|
||||||
bool premultipliedAlpha;
|
bool premultipliedAlpha;
|
||||||
cocos2d::BlendFunc blendFunc;
|
cocos2d::BlendFunc blendFunc;
|
||||||
|
|
||||||
static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
static Skeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
static Skeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
static Skeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
Skeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
Skeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
virtual ~CCSkeleton ();
|
virtual ~Skeleton ();
|
||||||
|
|
||||||
virtual void update (float deltaTime) override;
|
virtual void update (float deltaTime) override;
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
|
@ -93,7 +93,7 @@ public:
|
||||||
virtual void setBlendFunc(const cocos2d::BlendFunc& func) override;
|
virtual void setBlendFunc(const cocos2d::BlendFunc& func) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeleton ();
|
Skeleton ();
|
||||||
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
||||||
virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const;
|
virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const;
|
||||||
|
|
||||||
|
|
|
@ -43,28 +43,28 @@ using std::vector;
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
((CCSkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
((SkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
|
SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::initialize () {
|
void SkeletonAnimation::initialize () {
|
||||||
listenerInstance = 0;
|
listenerInstance = 0;
|
||||||
listenerMethod = 0;
|
listenerMethod = 0;
|
||||||
|
|
||||||
|
@ -74,27 +74,27 @@ void CCSkeletonAnimation::initialize () {
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (spSkeletonData *skeletonData)
|
SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData)
|
||||||
: CCSkeleton(skeletonData) {
|
: Skeleton(skeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
|
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
|
||||||
: CCSkeleton(skeletonDataFile, atlas, scale) {
|
: Skeleton(skeletonDataFile, atlas, scale) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale)
|
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale)
|
||||||
: CCSkeleton(skeletonDataFile, atlasFile, scale) {
|
: Skeleton(skeletonDataFile, atlasFile, scale) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::~CCSkeletonAnimation () {
|
SkeletonAnimation::~SkeletonAnimation () {
|
||||||
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
spAnimationState_dispose(state);
|
spAnimationState_dispose(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::update (float deltaTime) {
|
void SkeletonAnimation::update (float deltaTime) {
|
||||||
super::update(deltaTime);
|
super::update(deltaTime);
|
||||||
|
|
||||||
deltaTime *= timeScale;
|
deltaTime *= timeScale;
|
||||||
|
@ -103,7 +103,7 @@ void CCSkeletonAnimation::update (float deltaTime) {
|
||||||
spSkeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
||||||
CCAssert(stateData, "stateData cannot be null.");
|
CCAssert(stateData, "stateData cannot be null.");
|
||||||
|
|
||||||
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
|
@ -115,46 +115,46 @@ void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
||||||
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) {
|
void SkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) {
|
||||||
listenerInstance = instance;
|
listenerInstance = instance;
|
||||||
listenerMethod = method;
|
listenerMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
spTrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
log("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
|
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
log("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) {
|
spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) {
|
||||||
return spAnimationState_getCurrent(state, trackIndex);
|
return spAnimationState_getCurrent(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTracks () {
|
void SkeletonAnimation::clearTracks () {
|
||||||
spAnimationState_clearTracks(state);
|
spAnimationState_clearTracks(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTrack (int trackIndex) {
|
void SkeletonAnimation::clearTrack (int trackIndex) {
|
||||||
spAnimationState_clearTrack(state, trackIndex);
|
spAnimationState_clearTrack(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
void SkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,25 +40,25 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class CCSkeletonAnimation;
|
class SkeletonAnimation;
|
||||||
typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
||||||
|
|
||||||
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
||||||
* played later. */
|
* played later. */
|
||||||
class CCSkeletonAnimation: public CCSkeleton {
|
class SkeletonAnimation: public Skeleton {
|
||||||
public:
|
public:
|
||||||
spAnimationState* state;
|
spAnimationState* state;
|
||||||
|
|
||||||
static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData);
|
static SkeletonAnimation* createWithData (spSkeletonData* skeletonData);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
CCSkeletonAnimation (spSkeletonData* skeletonData);
|
SkeletonAnimation (spSkeletonData* skeletonData);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
virtual ~CCSkeletonAnimation ();
|
virtual ~SkeletonAnimation ();
|
||||||
|
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
|
|
||||||
|
@ -75,10 +75,10 @@ public:
|
||||||
virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
|
virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeletonAnimation ();
|
SkeletonAnimation ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CCSkeleton super;
|
typedef Skeleton super;
|
||||||
cocos2d::Object* listenerInstance;
|
cocos2d::Object* listenerInstance;
|
||||||
SEL_AnimationStateEvent listenerMethod;
|
SEL_AnimationStateEvent listenerMethod;
|
||||||
bool ownsAnimationStateData;
|
bool ownsAnimationStateData;
|
||||||
|
|
|
@ -49,7 +49,7 @@ void SpineTestScene::runThisTest()
|
||||||
bool SpineTestLayer::init () {
|
bool SpineTestLayer::init () {
|
||||||
if (!Layer::init()) return false;
|
if (!Layer::init()) return false;
|
||||||
|
|
||||||
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
skeletonNode = SkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
||||||
skeletonNode->setMix("walk", "jump", 0.2f);
|
skeletonNode->setMix("walk", "jump", 0.2f);
|
||||||
skeletonNode->setMix("jump", "walk", 0.4f);
|
skeletonNode->setMix("jump", "walk", 0.4f);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void SpineTestLayer::update (float deltaTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineTestLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
void SpineTestLayer::animationStateEvent (SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
||||||
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ public:
|
||||||
|
|
||||||
class SpineTestLayer: public cocos2d::Layer {
|
class SpineTestLayer: public cocos2d::Layer {
|
||||||
private:
|
private:
|
||||||
spine::CCSkeletonAnimation* skeletonNode;
|
spine::SkeletonAnimation* skeletonNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool init ();
|
virtual bool init ();
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
void animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
CREATE_FUNC (SpineTestLayer);
|
CREATE_FUNC (SpineTestLayer);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[cocos2dx_spine]
|
[cocos2dx_spine]
|
||||||
prefix = cocos2dx_spine
|
prefix = cocos2dx_spine
|
||||||
|
|
||||||
target_namespace = cc
|
target_namespace = sp
|
||||||
|
|
||||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||||
android_flags = -D_SIZE_T_DEFINED_
|
android_flags = -D_SIZE_T_DEFINED_
|
||||||
|
@ -20,12 +20,12 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s
|
||||||
|
|
||||||
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
|
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
|
||||||
|
|
||||||
skip = CCSkeleton::[createWithData],
|
skip = Skeleton::[createWithData],
|
||||||
CCSkeletonAnimation::[createWithData]
|
SkeletonAnimation::[createWithData]
|
||||||
|
|
||||||
classes = CCSkeleton CCSkeletonAnimation
|
classes = Skeleton SkeletonAnimation
|
||||||
|
|
||||||
remove_prefix = CC
|
remove_prefix =
|
||||||
|
|
||||||
classes_have_no_parents =
|
classes_have_no_parents =
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue