Merge pull request #11071 from pipu/reconstruct_ColorFrame

Reconstruct ColorFrame.
This commit is contained in:
minggo 2015-03-24 16:29:55 +08:00
commit e50a71609f
3 changed files with 5 additions and 15 deletions

View File

@ -350,12 +350,10 @@ Frame* ActionTimelineCache::loadColorFrame(const rapidjson::Value& json)
{
ColorFrame* frame = ColorFrame::create();
GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA);
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED);
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN);
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE);
frame->setAlpha(alpha);
frame->setColor(Color3B(red, green, blue));
return frame;

View File

@ -595,20 +595,16 @@ ColorFrame* ColorFrame::create()
}
ColorFrame::ColorFrame()
: _alpha(255)
, _color(Color3B(255, 255, 255))
: _color(Color3B(255, 255, 255))
{
}
void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
_node->setOpacity(_alpha);
_node->setColor(_color);
if(_tween)
{
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
const Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
_betweenRed = color.r - _color.r;
_betweenGreen = color.g - _color.g;
@ -618,16 +614,13 @@ void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
void ColorFrame::apply(float percent)
{
if (_tween && (_betweenAlpha !=0 || _betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0))
if (_tween && (_betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0))
{
GLubyte alpha = _alpha + _betweenAlpha * percent;
Color3B color;
color.r = _color.r+ _betweenRed * percent;
color.g = _color.g+ _betweenGreen * percent;
color.b = _color.b+ _betweenBlue * percent;
_node->setOpacity(alpha);
_node->setColor(color);
}
}
@ -635,7 +628,6 @@ void ColorFrame::apply(float percent)
Frame* ColorFrame::clone()
{
ColorFrame* frame = ColorFrame::create();
frame->setAlpha(_alpha);
frame->setColor(_color);
frame->cloneProperty(this);

View File

@ -299,8 +299,9 @@ public:
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
inline GLubyte getAlpha() const { return _alpha; }
/** @deprecated Use method setAlpha() and getAlpha() of AlphaFrame instead */
CC_DEPRECATED_ATTRIBUTE inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
CC_DEPRECATED_ATTRIBUTE inline GLubyte getAlpha() const { return _alpha; }
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
inline cocos2d::Color3B getColor() const { return _color; }
@ -309,7 +310,6 @@ protected:
GLubyte _alpha;
cocos2d::Color3B _color;
int _betweenAlpha;
int _betweenRed;
int _betweenGreen;
int _betweenBlue;