【问题标题】:Sprite Colliding With Screen Bottom?精灵与屏幕底部碰撞?
【发布时间】:2014-02-01 12:42:51
【问题描述】:

我的场景有一个[SKPhysicsBody bodyWithEdgeLoopFromRect: self.frame]。当 sprite 仅与屏幕底部发生碰撞时,我如何进行操作?

【问题讨论】:

  • 您应该添加节点来表示底部边缘,并将物理体添加到该节点。并在那个身体上发生碰撞。

标签: ios iphone collision sprite-kit skphysicsbody


【解决方案1】:

因此,使用`SKPhysicsBodybodyWithEdgeFromPoint:toPoint: 消息创建一个仅代表屏幕底部的正文。比如:

const int buffer = 100;
SKPhysicsBody *myBody = [bodyWithEdgeFromPoint:CGPointMake(-buffer, screenHeight) toPoint:CGPointMake(screenWidth + buffer, screenHeight)];

注意缓冲区以防止事物从“边缘”掉落,直到它们完全离开屏幕(更改常量以适应您的用例)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 2012-03-04
    • 1970-01-01
    相关资源
    最近更新 更多