ios - restitution (bouncing) not working -
import spritekit class gamescene: skscene { override func didmovetoview(view: skview) { /* setup scene here */ let border = skphysicsbody(edgeloopfromrect: self.frame) border.friction = 0 self.physicsbody = border self.physicsworld.gravity = cgvectormake(0, 0) let ball = childnodewithname ("ball") skspritenode ball.physicsbody?.applyimpulse(cgvectormake(30, -30)) ball.physicsbody?.allowsrotation = false ball.physicsbody?.restitution = 1 ball.physicsbody?.lineardamping = 0 ball.physicsbody?.angulardamping = 0 } override func touchesbegan(touches: nsset, withevent event: uievent) { /* called when touch begins */ } override func update(currenttime: cftimeinterval) { /* called before each frame rendered */ } }
Comments
Post a Comment