I'm creating a semi-circle node when i try to develop a simple sprite kit game, but i wish the physics body of the node just cover the circle object's edge, and the physics body rotates with the circle(to change the physics body programatically), what should i do?
Asked
Active
Viewed 1,173 times
1 Answers
1
You can do complex shapes using SKPhysicsBody -bodyWithPolygonFromPath:
There are even tools that let you draw your shape and generate the code for you. See this question for examples: SpriteKit's SKPhysicsBody with polygon helper tool

Community
- 1
- 1

Filip Radelic
- 26,607
- 8
- 71
- 97
-
So complicated!what if i just need the edge of the semi-circle? – luckyee Mar 04 '14 at 08:02
-
Got it. Use CGPathAddArc and [SKPhysicsBody bodyWithEdgeChainFromPath] instead of bodyWithPolygonFromPath – luckyee Mar 04 '14 at 09:51
-
That will give you an edge, not a body. Edges behave a lot differently that bodies and you probably don't want that. You should really use -bodyWithPolygonFromPath: – Filip Radelic Mar 04 '14 at 13:25
-
Also, read the [Sprite Kit Programming Guide](https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Physics/Physics.html). – Filip Radelic Mar 04 '14 at 13:26