【发布时间】:2013-04-10 08:31:49
【问题描述】:
当我创建一个精灵批处理节点时,边界框是空的。如何获取精灵批处理节点的边界框或矩形,以便可以将其用于碰撞。
【问题讨论】:
-
不知道为什么我会被否决
标签: iphone ios objective-c cocos2d-iphone
当我创建一个精灵批处理节点时,边界框是空的。如何获取精灵批处理节点的边界框或矩形,以便可以将其用于碰撞。
【问题讨论】:
标签: iphone ios objective-c cocos2d-iphone
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;
}
【讨论】: