0

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?

user717452
  • 33
  • 14
  • 73
  • 149
  • This is essentially a duplicate of : http://stackoverflow.com/questions/19040144/spritekits-skphysicsbody-with-polygon-helper-tool – prototypical Oct 23 '14 at 12:59

1 Answers1

2

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:.

Dobroćudni Tapir
  • 3,082
  • 20
  • 37