2013-04-10 55 views
-4

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

+0

不知道为什么我得到downvoted – user2121776 2013-04-10 08:55:48

回答

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; 
} 
+0

感谢您的帮助。 – user2121776 2013-04-10 08:56:06