From 538da31773b8aef89071b5ca8bf104460ae6a51d Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 25 Dec 2013 11:18:14 +0800 Subject: [PATCH] Removes CC prefix for CCSkeleton and CCSkeletonAnimation. Adds namespace `sp` for JSBindings. --- cocos/editor-support/spine/CCSkeleton.cpp | 58 +++++++++---------- cocos/editor-support/spine/CCSkeleton.h | 18 +++--- .../spine/CCSkeletonAnimation.cpp | 54 ++++++++--------- .../spine/CCSkeletonAnimation.h | 24 ++++---- .../TestCpp/Classes/SpineTest/SpineTest.cpp | 4 +- .../Cpp/TestCpp/Classes/SpineTest/SpineTest.h | 4 +- tools/tojs/cocos2dx_spine.ini | 10 ++-- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index a194809d41..70c342c53d 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -40,25 +40,25 @@ using std::max; namespace spine { -CCSkeleton* CCSkeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) { - CCSkeleton* node = new CCSkeleton(skeletonData, isOwnsSkeletonData); +Skeleton* Skeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) { + Skeleton* node = new Skeleton(skeletonData, isOwnsSkeletonData); node->autorelease(); return node; } -CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { - CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale); +Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { + Skeleton* node = new Skeleton(skeletonDataFile, atlas, scale); node->autorelease(); return node; } -CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { - CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale); +Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { + Skeleton* node = new Skeleton(skeletonDataFile, atlasFile, scale); node->autorelease(); return node; } -void CCSkeleton::initialize () { +void Skeleton::initialize () { atlas = 0; debugSlots = false; debugBones = false; @@ -73,23 +73,23 @@ void CCSkeleton::initialize () { scheduleUpdate(); } -void CCSkeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { +void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { skeleton = spSkeleton_create(skeletonData); rootBone = skeleton->bones[0]; this->ownsSkeletonData = isOwnsSkeletonData; } -CCSkeleton::CCSkeleton () { +Skeleton::Skeleton () { initialize(); } -CCSkeleton::CCSkeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { +Skeleton::Skeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { initialize(); setSkeletonData(skeletonData, isOwnsSkeletonData); } -CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) { +Skeleton::Skeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) { initialize(); spSkeletonJson* json = spSkeletonJson_create(aAtlas); @@ -101,7 +101,7 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float sca setSkeletonData(skeletonData, true); } -CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) { +Skeleton::Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale) { initialize(); atlas = spAtlas_readAtlasFile(atlasFile); @@ -116,17 +116,17 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, flo setSkeletonData(skeletonData, true); } -CCSkeleton::~CCSkeleton () { +Skeleton::~Skeleton () { if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data); if (atlas) spAtlas_dispose(atlas); spSkeleton_dispose(skeleton); } -void CCSkeleton::update (float deltaTime) { +void Skeleton::update (float deltaTime) { spSkeleton_update(skeleton, deltaTime * timeScale); } -void CCSkeleton::draw () { +void Skeleton::draw () { CC_NODE_DRAW_SETUP(); 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; } -Rect CCSkeleton::getBoundingBox () const { +Rect Skeleton::getBoundingBox () const { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = getScaleX(); float scaleY = getScaleY(); @@ -259,50 +259,50 @@ Rect CCSkeleton::getBoundingBox () const { // --- Convenience methods for Skeleton_* functions. -void CCSkeleton::updateWorldTransform () { +void Skeleton::updateWorldTransform () { spSkeleton_updateWorldTransform(skeleton); } -void CCSkeleton::setToSetupPose () { +void Skeleton::setToSetupPose () { spSkeleton_setToSetupPose(skeleton); } -void CCSkeleton::setBonesToSetupPose () { +void Skeleton::setBonesToSetupPose () { spSkeleton_setBonesToSetupPose(skeleton); } -void CCSkeleton::setSlotsToSetupPose () { +void Skeleton::setSlotsToSetupPose () { spSkeleton_setSlotsToSetupPose(skeleton); } -spBone* CCSkeleton::findBone (const char* boneName) const { +spBone* Skeleton::findBone (const char* boneName) const { return spSkeleton_findBone(skeleton, boneName); } -spSlot* CCSkeleton::findSlot (const char* slotName) const { +spSlot* Skeleton::findSlot (const char* slotName) const { return spSkeleton_findSlot(skeleton, slotName); } -bool CCSkeleton::setSkin (const char* skinName) { +bool Skeleton::setSkin (const char* skinName) { 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); } -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; } // --- CCBlendProtocol -const cocos2d::BlendFunc& CCSkeleton::getBlendFunc () const { +const cocos2d::BlendFunc& Skeleton::getBlendFunc () const { return blendFunc; } -void CCSkeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) { +void Skeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) { this->blendFunc = aBlendFunc; } -void CCSkeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture) +void Skeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture) { if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha()) { diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index abeb3fa8ce..ab4270be0d 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -42,7 +42,7 @@ namespace spine { /** Draws a skeleton. */ -class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol { +class Skeleton: public cocos2d::Node, public cocos2d::BlendProtocol { public: spSkeleton* skeleton; spBone* rootBone; @@ -52,15 +52,15 @@ public: bool premultipliedAlpha; cocos2d::BlendFunc blendFunc; - static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); - static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); + static Skeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); + static Skeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); + static Skeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); - CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); - CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0); + Skeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false); + Skeleton (const char* skeletonDataFile, spAtlas* atlas, 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 draw() override; @@ -93,7 +93,7 @@ public: virtual void setBlendFunc(const cocos2d::BlendFunc& func) override; protected: - CCSkeleton (); + Skeleton (); void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData); virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const; diff --git a/cocos/editor-support/spine/CCSkeletonAnimation.cpp b/cocos/editor-support/spine/CCSkeletonAnimation.cpp index c899de17c2..f4cd9dab9a 100644 --- a/cocos/editor-support/spine/CCSkeletonAnimation.cpp +++ b/cocos/editor-support/spine/CCSkeletonAnimation.cpp @@ -43,28 +43,28 @@ using std::vector; namespace spine { 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) { - CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData); +SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData) { + SkeletonAnimation* node = new SkeletonAnimation(skeletonData); node->autorelease(); return node; } -CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { - CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale); +SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { + SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale); node->autorelease(); return node; } -CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { - CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlasFile, scale); +SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { + SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale); node->autorelease(); return node; } -void CCSkeletonAnimation::initialize () { +void SkeletonAnimation::initialize () { listenerInstance = 0; listenerMethod = 0; @@ -74,27 +74,27 @@ void CCSkeletonAnimation::initialize () { state->listener = callback; } -CCSkeletonAnimation::CCSkeletonAnimation (spSkeletonData *skeletonData) - : CCSkeleton(skeletonData) { +SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData) + : Skeleton(skeletonData) { initialize(); } -CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale) - : CCSkeleton(skeletonDataFile, atlas, scale) { +SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale) + : Skeleton(skeletonDataFile, atlas, scale) { initialize(); } -CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale) - : CCSkeleton(skeletonDataFile, atlasFile, scale) { +SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale) + : Skeleton(skeletonDataFile, atlasFile, scale) { initialize(); } -CCSkeletonAnimation::~CCSkeletonAnimation () { +SkeletonAnimation::~SkeletonAnimation () { if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); spAnimationState_dispose(state); } -void CCSkeletonAnimation::update (float deltaTime) { +void SkeletonAnimation::update (float deltaTime) { super::update(deltaTime); deltaTime *= timeScale; @@ -103,7 +103,7 @@ void CCSkeletonAnimation::update (float deltaTime) { spSkeleton_updateWorldTransform(skeleton); } -void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) { +void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) { CCAssert(stateData, "stateData cannot be null."); if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); @@ -115,46 +115,46 @@ void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData 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); } -void CCSkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) { +void SkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) { listenerInstance = instance; 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); if (!animation) { - CCLog("Spine: Animation not found: %s", name); + log("Spine: Animation not found: %s", name); return 0; } 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); if (!animation) { - CCLog("Spine: Animation not found: %s", name); + log("Spine: Animation not found: %s", name); return 0; } return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay); } -spTrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) { +spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) { return spAnimationState_getCurrent(state, trackIndex); } -void CCSkeletonAnimation::clearTracks () { +void SkeletonAnimation::clearTracks () { spAnimationState_clearTracks(state); } -void CCSkeletonAnimation::clearTrack (int trackIndex) { +void SkeletonAnimation::clearTrack (int 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); } diff --git a/cocos/editor-support/spine/CCSkeletonAnimation.h b/cocos/editor-support/spine/CCSkeletonAnimation.h index 784a6771a5..228a07b88e 100644 --- a/cocos/editor-support/spine/CCSkeletonAnimation.h +++ b/cocos/editor-support/spine/CCSkeletonAnimation.h @@ -40,25 +40,25 @@ namespace spine { -class CCSkeletonAnimation; -typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); +class SkeletonAnimation; +typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); #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 * played later. */ -class CCSkeletonAnimation: public CCSkeleton { +class SkeletonAnimation: public Skeleton { public: spAnimationState* state; - static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData); - static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); - static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); + static SkeletonAnimation* createWithData (spSkeletonData* skeletonData); + static SkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); + static SkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); - CCSkeletonAnimation (spSkeletonData* skeletonData); - CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); - CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0); + SkeletonAnimation (spSkeletonData* skeletonData); + SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); + SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0); - virtual ~CCSkeletonAnimation (); + virtual ~SkeletonAnimation (); virtual void update (float deltaTime); @@ -75,10 +75,10 @@ public: virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount); protected: - CCSkeletonAnimation (); + SkeletonAnimation (); private: - typedef CCSkeleton super; + typedef Skeleton super; cocos2d::Object* listenerInstance; SEL_AnimationStateEvent listenerMethod; bool ownsAnimationStateData; diff --git a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp index 7d70a87640..78e70ba8e8 100644 --- a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp @@ -49,7 +49,7 @@ void SpineTestScene::runThisTest() bool SpineTestLayer::init () { 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("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); const char* animationName = (entry && entry->animation) ? entry->animation->name : 0; diff --git a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.h b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.h index a5c9d83ddd..33eea39c34 100644 --- a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.h +++ b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.h @@ -38,13 +38,13 @@ public: class SpineTestLayer: public cocos2d::Layer { private: - spine::CCSkeletonAnimation* skeletonNode; + spine::SkeletonAnimation* skeletonNode; public: virtual bool init (); 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); }; diff --git a/tools/tojs/cocos2dx_spine.ini b/tools/tojs/cocos2dx_spine.ini index 62f4ba8f6a..9a6507072e 100644 --- a/tools/tojs/cocos2dx_spine.ini +++ b/tools/tojs/cocos2dx_spine.ini @@ -1,7 +1,7 @@ [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_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 -skip = CCSkeleton::[createWithData], - CCSkeletonAnimation::[createWithData] +skip = Skeleton::[createWithData], + SkeletonAnimation::[createWithData] -classes = CCSkeleton CCSkeletonAnimation +classes = Skeleton SkeletonAnimation -remove_prefix = CC +remove_prefix = classes_have_no_parents =