I have a class named Ball who extends SKSpriteNode class:
import SpriteKit
class Ball: SKSpriteNode {
var score: Int = 0
init([...]){
[...]
}
func setScore(score: Int){
self.score = score;
}
}
In my GameScene, I detect collisions on my element :
func didBegin(_ contact: SKPhysicsContact) {
[...]
// Here I want to call my function in Ball class, but I can't.
contact.bodyA.node!.setPoints(2);
[...]
}
How can I call setScore() in didBegin() from contact variable?
Thanks