The CCScale9Sprite in Cocos2d-x v2.1rc0-x-2.1.2 has some bugs!
This version “setColor” and “setOpacity” didn’t work!
The CCScale9Sprite in Cocos2d-x v2.1rc0-x-2.1.2 has some bugs!
This version “setColor” and “setOpacity” didn’t work!
same problem here
@minggo, why remove the setColor/setOpacity code from CCScale9Sprite.cpp & CCProgressTimer?
I think you should revert all setColor/setOpacity which were deleted when you synchronized code with cocos2d-iphone. c++ is not that dynamic as objc.
I think you are right. We should revert those functions for CCScale9Sprite.
If opacity and/or color are set early enough (like during init of a parent node), and the *scale9Image isn’t init’d yet, the existing code will crash. The fix is to check if it is init’d and quit if not.
<pre>
void CCScale9Sprite::setColor
{
*color = color;
if (*scale9Image NULL) return; // _scale9Image not init’d yet
CCObject\* child;
CCArray\* children = \_scale9Image-\>getChildren();
CCARRAY\_FOREACH(children, child)
{
CCRGBAProtocol\* pNode = dynamic\_cast\<CCRGBAProtocol\*\>(child);
if (pNode)
{
pNode-\>setColor(color);
}
}
}
void CCScale9Sprite::setOpacity(GLubyte opacity)
{
_opacity = opacity;
if (\_scale9Image NULL) return; //*scale9Image not init’d yet
CCObject* child;
CCArray* children = _scale9Image~~>getChildren;
CCARRAY_FOREACH
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>;
if
{
pNode~~>setOpacity(opacity);
}
}
}
James Chen wrote:
Fixed at https://github.com/cocos2d/cocos2d-x/pull/2373. Thanks for your feedback.
@James Chen, you should also revert back the setColor/setOpacity for CCProgressTimer
Le Yang wrote:
James Chen wrote:
> Fixed at https://github.com/cocos2d/cocos2d-x/pull/2373. Thanks for your feedback.
>
`James Chen, you should revert back setColor()/setOpacity() for CCProgressTimer too
`James Chen, I checkout your fix after updating to cocos2dx-v2.1.3. It’s wrong. You should not add new member var *opacity&*color, and get value from *realOpacity&*realColor. Use _realOpacity&realColor from CCNodeRGBA both.
Again, please revert back setColor()/setOpacity() for CCProgressTimer too
Hi,
i have the same issue for 2.1.4. Is there any best practice how to workaround/fix?
Fixed at cocos2d-x-3.0-alpha0-pre .
Hi,
can you share information how to merge your fix in 2.1.4? I update cocos2dx from 2.0.4 to 2.1.4 two days ago and i do not want to update to a pre alpha version. Especially since all last updates had massive impact, because cocosbuilder or extensions did not work properly with the new versions. And these updates were tagged stable.