diff --git a/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h b/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h index b14cb83aa..297302a4f 100644 --- a/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h +++ b/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h @@ -35,7 +35,7 @@ class Skeleton; class AnimationState; class AnimationStateData; -class CCSkeleton: public cocos2d::CCNode, public cocos2d::CCRGBAProtocol, public cocos2d::CCBlendProtocol { +class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol { public: Skeleton *skeleton; AnimationState *state; @@ -48,14 +48,6 @@ public: virtual void update (float deltaTime); virtual void draw (); - // CCRGBAProtocol - CC_PROPERTY_PASS_BY_REF(cocos2d::ccColor3B, color, Color); - cocos2d::ccColor3B colorUnmodified; - CC_PROPERTY(GLubyte, opacity, Opacity); - bool opacityModifyRGB; - bool isOpacityModifyRGB (); - void setOpacityModifyRGB (bool isOpacityModifyRGB); - // CCBlendProtocol CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc); }; diff --git a/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp b/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp index e57214a83..2cdb938df 100644 --- a/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp +++ b/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp @@ -44,17 +44,11 @@ CCSkeleton* CCSkeleton::create (SkeletonData* skeletonData) { } CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) : - opacity(255), - opacityModifyRGB(false), debug(false) { if (!skeletonData) throw std::invalid_argument("skeletonData cannot be null."); skeleton = new Skeleton(skeletonData); state = new AnimationState(stateData); - color.r = 255; - color.g = 255; - color.b = 255; - colorUnmodified = color; blendFunc.src = CC_BLEND_SRC; blendFunc.dst = CC_BLEND_DST; @@ -78,10 +72,11 @@ void CCSkeleton::draw () { CC_NODE_DRAW_SETUP(); ccGLBlendFunc(blendFunc.src, blendFunc.dst); + ccColor3B color = getColor(); skeleton->r = color.r / (float)255; skeleton->g = color.g / (float)255; skeleton->b = color.b / (float)255; - skeleton->a = opacity / (float)255; + skeleton->a = getOpacity() / (float)255; skeleton->draw(); if (debug) { @@ -118,42 +113,6 @@ void CCSkeleton::draw () { } } -// CCSkeleton - RGBA protocol - -const ccColor3B& CCSkeleton::getColor () { - if (opacityModifyRGB) return colorUnmodified; - return color; -} - -void CCSkeleton::setColor (const ccColor3B& color) { - this->color = colorUnmodified = color; - if (opacityModifyRGB) { - this->color.r = color.r * opacity / 255; - this->color.g = color.g * opacity / 255; - this->color.b = color.b * opacity / 255; - } -} - -GLubyte CCSkeleton::getOpacity () { - return opacity; -} - -void CCSkeleton::setOpacity (GLubyte opacity) { - this->opacity = opacity; - // Special opacity for premultiplied textures. - if (opacityModifyRGB) this->setColor(colorUnmodified); -} - -void CCSkeleton::setOpacityModifyRGB (bool isOpacityModifyRGB) { - ccColor3B oldColor = this->getColor(); - opacityModifyRGB = isOpacityModifyRGB; - this->setColor(oldColor); -} - -bool CCSkeleton::isOpacityModifyRGB () { - return opacityModifyRGB; -} - // CCBlendProtocol ccBlendFunc CCSkeleton::getBlendFunc () {