Hi every body,
during my current porting from cocos2D to cocos2D-X i found an error in the code of CCRect CCControlUtils::CCRectUnion(const CCRect& src1, const CCRect& src2)
from the current cocos2D-x version :
CCRect CCControlUtils::CCRectUnion(const CCRect& src1, const CCRect& src2)
{
CCRect result;
float x1 = MIN (src1.getMinX(), src2.getMinX());
float y1 = MIN (src1.getMinY(), src2.getMinY());
float x2 = MAX (src1.getMaxX(), src2.getMaxX());
float y2 = MAX (src1.getMaxY(), src2.getMaxY());
result.origin=ccp(x1,x2); // HERE IS THE PROBLEM
result.size=CCSizeMake(x2-x1, y2-y1);
return result;
}
the “good version” :
CCRect CCControlUtils::CCRectUnion(const CCRect& src1, const CCRect& src2)
{
CCRect result;
float x1 = MIN (src1.getMinX(), src2.getMinX());
float y1 = MIN (src1.getMinY(), src2.getMinY());
float x2 = MAX (src1.getMaxX(), src2.getMaxX());
float y2 = MAX (src1.getMaxY(), src2.getMaxY());
result.origin=ccp(x1,y1); // THE SOLUTION…
result.size=CCSizeMake(x2-x1, y2-y1);
return result;
}
Regards,
JC