http://www.cocos2d-x.org/forums/6/topics/41700
当CCArmature有子CCArmature时,发现boundingBox差点有点远,hack了一下源码,
CCRect CCArmature::boundingBox()
{
float minx, miny, maxx, maxy = 0;
bool first = true;
CCRect boundingBox = CCRectMake(0, 0, 0, 0);
CCObject *object = NULL;
CCARRAY_FOREACH(m_pChildren, object)
{
if (CCBone *bone = dynamic_cast<CCBone *>(object))
{
CCArmature* child = bone->getChildArmature();
//CCRect r = bone->getDisplayManager()->getBoundingBox();//hack by HanHongmin 2013-12-29
CCRect r;
if(child!=NULL){
r = child->boundingBox();
}else{
r = bone->getDisplayManager()->getBoundingBox();
}
//hack finish
if(first)
{
minx = r.getMinX();
miny = r.getMinY();
maxx = r.getMaxX();
maxy = r.getMaxY();
first = false;
}
else
{
minx = r.getMinX() < boundingBox.getMinX() ? r.getMinX() : boundingBox.getMinX();
miny = r.getMinY() < boundingBox.getMinY() ? r.getMinY() : boundingBox.getMinY();
maxx = r.getMaxX() > boundingBox.getMaxX() ? r.getMaxX() : boundingBox.getMaxX();
maxy = r.getMaxY() > boundingBox.getMaxY() ? r.getMaxY() : boundingBox.getMaxY();
}
boundingBox.setRect(minx, miny, maxx - minx, maxy - miny);
}
}
return CCRectApplyAffineTransform(boundingBox, nodeToParentTransform());
}
不知道是不是bug,也不知道改的对不对,反正最终效果还可以。
新手求指导啊~~~~