Is it possible to add two (ore more) SKPhysicsBodys to one SKNode? Something similar to this: Example from PhysicsEditor Because the head of the character should collide with a ball, the top should be round. Furthermore the ball mustn't go through the player. Do you have an idea how to accomplish this?
相关问题
- Why shouldn't I use pixels as unit with Box2D?
- Change a SKPhysicsBody's body shape
- @objc protocol crashes the swift compiler
- Getting UITableViewCell from its superview iOS 7 i
- SKSpriteNode created from SKTexture(data:size:) is
相关文章
- didBeginContact:(SKPhysicsContact *)contact not in
- ios7 new pan gesture to go back in navigation stac
- IOS UICollectionview Dynamically change Cell's
- How do you use SKTextureFilteringNearest with SKTe
- PhoneGap iOS 7 and localStorage
- Can I add a border to an SKSpriteNode, similar to
- Add UITextField to title view of navigation item
- Position resizable circles near each other
This is the top hit on Google for this question so i thought I'd update the answers. This is possible (Although may not have been in 2013), as per the answer from Mike S in this post.
You need to use
So you create a body with other bodies and add that one body to your
SKnode
.As the
physicsBody
property onSKNode
suggests, there's a one-to-one relationship between nodes and physics bodies.However, that doesn't mean you have to have one basic shape for every visible sprite. There are a few approaches you can take to accomplish what you're looking for:
No, every
SKNode
can only have oneSKPhysicsBody
sincephysicsBody
is a single property ofSKNode
. Like rickster said, your first option is to make the monkey one silo-shaped physics body using thebodyWithEdgeLoopFromRect:
class method ofSKPhysicsBody
.Your other option is to create two separate
SKNodes
and attach them with anSKPhysicsJointFixed
. rickster's answer is great, but I just wanted to give the class names in case you want to do a little Googling around.