【发布时间】:2014-11-05 17:44:12
【问题描述】:
如何检测精灵中边界框底部的方法?
我使用CGRectIntersectsRect 检测触摸但我只想检测_ball.boundingbox 底部的触摸
if(CGRectIntersectsRect(_ball.boundingBox, sprite.boundingBox)){
}
【问题讨论】:
标签: ios cocos2d-iphone bounding-box
如何检测精灵中边界框底部的方法?
我使用CGRectIntersectsRect 检测触摸但我只想检测_ball.boundingbox 底部的触摸
if(CGRectIntersectsRect(_ball.boundingBox, sprite.boundingBox)){
}
【问题讨论】:
标签: ios cocos2d-iphone bounding-box
您可以创建一个高度非常小的矩形来模拟边界框的底线,并使用您在上面给出的代码(类似这些行)检测碰撞。
CGRect bottomLineRect = CGRectMake(_ball.position.x,_ball.position.y,_ball.boundingBox.size.width, 1);
if(CGRectIntersectsRect(bottomLineRect, sprite.boundingBox)){
// collision code here
}
【讨论】: