【问题标题】:Detect bottom of bounding box - Cocos2d检测边界框的底部 - Cocos2d
【发布时间】:2014-11-05 17:44:12
【问题描述】:

如何检测精灵中边界框底部的方法?

我使用CGRectIntersectsRect 检测触摸但我只想检测_ball.boundingbox 底部的触摸

 if(CGRectIntersectsRect(_ball.boundingBox, sprite.boundingBox)){
}

【问题讨论】:

    标签: ios cocos2d-iphone bounding-box


    【解决方案1】:

    您可以创建一个高度非常小的矩形来模拟边界框的底线,并使用您在上面给出的代码(类似这些行)检测碰撞。

    CGRect bottomLineRect = CGRectMake(_ball.position.x,_ball.position.y,_ball.boundingBox.size.width, 1);
    if(CGRectIntersectsRect(bottomLineRect, sprite.boundingBox)){
        // collision code here
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 2012-07-12
      • 2015-02-01
      • 2014-02-04
      相关资源
      最近更新 更多