user717452
user717452

Reputation: 111

SpriteKit bodyWithTexture equivalent in iOS 7.1

In my game that uses SpriteKit, I have a line of code used for mapping objects based on the part of the image that is actually an object, instead of all the transparent objects:

bg.physicsBody = [SKPhysicsBody bodyWithTexture:bg.texture size:bg.texture.size];

However, the bodyWithTexture only works on iOS 8.0. Is there an equivalent to this on 7.1 and below?

Upvotes: 0

Views: 323

Answers (1)

Dobroćudni Tapir
Dobroćudni Tapir

Reputation: 3102

bodyWithTexture is only available in iOS 8.0 and later.

Best way to handle this in iOS7.1 is to createCGPath that resembles the outline of your texture and use it to create physics body using bodyWithPolygonFromPath:.

Upvotes: 2

Related Questions