Reputation: 83
My scene has a [SKPhysicsBody bodyWithEdgeLoopFromRect: self.frame]
. How can I make an action when a sprite collide only with the bottom of the screen?
Upvotes: 0
Views: 379
Reputation: 49376
So, create a body that represents only the bottom of the screen with `SKPhysicsBody
's bodyWithEdgeFromPoint:toPoint:
message. Something like:
const int buffer = 100;
SKPhysicsBody *myBody = [bodyWithEdgeFromPoint:CGPointMake(-buffer, screenHeight) toPoint:CGPointMake(screenWidth + buffer, screenHeight)];
Notice the buffer to prevent things from falling off the "edge" until they're off the screen entirely (alter the constant to fit your use case).
Upvotes: 1