【问题标题】:Bounding box with spritebatchnode [closed]带有 spritebatchnode 的边界框 [关闭]
【发布时间】:2013-04-10 08:31:49
【问题描述】:

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

【问题讨论】:

  • 不知道为什么我会被否决

标签: iphone ios objective-c cocos2d-iphone


【解决方案1】:

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-07-30
    • 1970-01-01
    • 2021-06-15
    • 2016-12-21
    • 1970-01-01
    • 1970-01-01
    • 2016-04-05
    • 2018-01-13
    • 1970-01-01
    相关资源
    最近更新 更多