I created a class that declare a ball of kind 'SKShapeNode'. in its init I set the 'SKPhysicsBody' properties. before I set these properties (leave it as default) when one ball touch another one the both affected by the touch (like: move to different position depends on the collision position). after I set the 'physicsBody' properties it won't affected any more - one ball appear to be above the other one (like frame on frame - hiding it). how can I set this property? I look at apple doc and did find nothing... here is my code:
lass BallNode: SKShapeNode {
var radius:CGFloat = 0
var color:UIColor?
var strokeWidth:CGFloat = 0
private var _name:String?
override init() {
super.init()
self.fillColor = ranColor()
self.lineWidth = strokeWidth
}
convenience init(radius:CGFloat){
self.init(circleOfRadius: radius)
self.radius = radius
self.physicsBody = SKPhysicsBody.init(circleOfRadius: self.radius)
self.physicsBody?.affectedByGravity = true
print("ball physicsbody is init")
self.physicsBody?.restitution = 0.2
self.physicsBody?.linearDamping = 0.0
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}