ios - Resizing a SpriteKit SKPhysicsBody created with SKPhysicsBody(circleOfRadius:) -
i building spritekit "chain reaction" game circles larger "explode". using skphysicsbody(circleofradius:) initializer create physics bodies circles.
unfortunately, these physics bodies don't seem re-size circles larger, , don't have exposed .radius property can set. there way resize physics body in spritekit, or need create new physics body every frame instead? (this have done below , code works fine, feels inefficient create new physics bodies in update loops.)
ps - know circles can accurate collision detection using trig distances, wanted use spritekit collision detection other effects.
func movecircles(dt:cgfloat){ enumeratechildnodeswithname("circle") { node, stop in let c = node as! circlesprite var halfwidth = c.size.width / 2.0 c.update(dt) // in update() exploding circles larger. if c.isexploding{ // fixme: have make new physics body every update - don't this! c.physicsbody = skphysicsbody(circleofradius: halfwidth) c.physicsbody?.categorybitmask = collisioncategories.explodingcircle c.physicsbody?.contacttestbitmask = collisioncategories.circle c.physicsbody?.collisionbitmask = 0 c.physicsbody?.dynamic = true // default } } }
you might want read more here. resizing physicsbody not possible , recommended create new physicsbody , assign node.
Comments
Post a Comment