重写boundingBox之--忽略锚点,放缩等因素,得到精灵碰撞区域

CCRect GameLayer::MyBoundingBox(CCNode* node)
{
    CCRect rect;
    rect.origin.x = node->getPositionX() - node->getContentSize().width * node->getScaleX() * node->getAnchorPoint().x;
    rect.origin.y = node->getPositionY() - node->getContentSize().height * node->getScaleY() * node->getAnchorPoint().y;
    rect.size.width = node->getContentSize().width * node->getScaleX();
    rect.size.height = node->getContentSize().height * node->getScaleY();
    return rect;
}

总结:origin指的是矩形区域的左下角!!!

你可能感兴趣的:(重写boundingBox之--忽略锚点,放缩等因素,得到精灵碰撞区域)