ios - SKShapeNode motionless when made the scene.frame a physicsBody -
it's first post in coding forum - means i'm reeaaaaallly stuck (i've searched everywhere , tested many options).
creating simple bouncing ball on ipad screen, coding app using spritekit.
the below code prevent ball move @ when remove skphysicsbody created out frame.edge : ball falls. i've got feeling self.physicsbody made volume despite ask made edge...
can please ?
override func didmove(to view: skview) { self.physicsworld.gravity = cgvector(dx: 0,dy: -6) self.physicsbody = skphysicsbody(edgeloopfrom: self.frame) // ball's cage self.physicsbody?.friction = 0; let fbound = skshapenode(rect: self.frame) fbound.linewidth = 1 fbound.strokecolor = .red addchild(fbound) let path = cgmutablepath() path.addarc(center: cgpoint(x: view.bounds.width / 2, y: view.bounds.height / 2), radius: 15, startangle: 0, endangle: cgfloat.pi * 2, clockwise: true) let ball = skshapenode(path: path) ball.linewidth = 1 ball.fillcolor = .red ball.strokecolor = .black ball.glowwidth = 0.5 ball.physicsbody = skphysicsbody(circleofradius: ball.frame.size.width/2) ball.physicsbody?.friction = 0 ball.physicsbody?.restitution = 1 ball.physicsbody?.mass = 0.6 ball.physicsbody?.lineardamping = 0 ball.physicsbody?.allowsrotation = false ball.physicsbody?.isdynamic = true addchild(ball) }
please let me know if need more details
thanks mil in advance
rgds
wiki
Comments
Post a Comment