mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Fixed for cocos2d-2.1rc0-x-2.1.2.
This commit is contained in:
parent
41b748ef4d
commit
f8dd23fc18
@ -35,7 +35,7 @@ class Skeleton;
|
|||||||
class AnimationState;
|
class AnimationState;
|
||||||
class AnimationStateData;
|
class AnimationStateData;
|
||||||
|
|
||||||
class CCSkeleton: public cocos2d::CCNode, public cocos2d::CCRGBAProtocol, public cocos2d::CCBlendProtocol {
|
class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol {
|
||||||
public:
|
public:
|
||||||
Skeleton *skeleton;
|
Skeleton *skeleton;
|
||||||
AnimationState *state;
|
AnimationState *state;
|
||||||
@ -48,14 +48,6 @@ public:
|
|||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
virtual void draw ();
|
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
|
// CCBlendProtocol
|
||||||
CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc);
|
CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -44,17 +44,11 @@ CCSkeleton* CCSkeleton::create (SkeletonData* skeletonData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) :
|
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) :
|
||||||
opacity(255),
|
|
||||||
opacityModifyRGB(false),
|
|
||||||
debug(false) {
|
debug(false) {
|
||||||
if (!skeletonData) throw std::invalid_argument("skeletonData cannot be null.");
|
if (!skeletonData) throw std::invalid_argument("skeletonData cannot be null.");
|
||||||
skeleton = new Skeleton(skeletonData);
|
skeleton = new Skeleton(skeletonData);
|
||||||
state = new AnimationState(stateData);
|
state = new AnimationState(stateData);
|
||||||
|
|
||||||
color.r = 255;
|
|
||||||
color.g = 255;
|
|
||||||
color.b = 255;
|
|
||||||
colorUnmodified = color;
|
|
||||||
blendFunc.src = CC_BLEND_SRC;
|
blendFunc.src = CC_BLEND_SRC;
|
||||||
blendFunc.dst = CC_BLEND_DST;
|
blendFunc.dst = CC_BLEND_DST;
|
||||||
|
|
||||||
@ -78,10 +72,11 @@ void CCSkeleton::draw () {
|
|||||||
CC_NODE_DRAW_SETUP();
|
CC_NODE_DRAW_SETUP();
|
||||||
|
|
||||||
ccGLBlendFunc(blendFunc.src, blendFunc.dst);
|
ccGLBlendFunc(blendFunc.src, blendFunc.dst);
|
||||||
|
ccColor3B color = getColor();
|
||||||
skeleton->r = color.r / (float)255;
|
skeleton->r = color.r / (float)255;
|
||||||
skeleton->g = color.g / (float)255;
|
skeleton->g = color.g / (float)255;
|
||||||
skeleton->b = color.b / (float)255;
|
skeleton->b = color.b / (float)255;
|
||||||
skeleton->a = opacity / (float)255;
|
skeleton->a = getOpacity() / (float)255;
|
||||||
skeleton->draw();
|
skeleton->draw();
|
||||||
|
|
||||||
if (debug) {
|
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
|
// CCBlendProtocol
|
||||||
|
|
||||||
ccBlendFunc CCSkeleton::getBlendFunc () {
|
ccBlendFunc CCSkeleton::getBlendFunc () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user