-4

当我制作一个精灵批处理节点时,边界框是空的。我如何获得精灵批处理节点的边界框或矩形,以便我可以将其用于碰撞。

4

1 回答 1

2

SpriteBatch boundingBox 始终为空。但作为替代方案,您可以使用精灵批处理子项的边界框来检查碰撞

CCArray* children = _gameBatch.children;
NSUInteger childrenCount = children.count;
CCSprite* child;
for (NSUInteger pos = 0; pos < childrenCount; pos++) {
    child = [children objectAtIndex:pos];
    CGRect box = child.boundingBox;
}
于 2013-04-10T08:48:12.957 回答