Answer the question
In order to leave comments, you need to log in
How to make SKSpriteNodes interact?
I already did everything, but for some reason the interaction of objects in didBegin does not work
What code I have:
enemy.physicsBody = SKPhysicsBody(rectangleOf: enemy.size)
enemy.physicsBody?.isDynamic = false
enemy.physicsBody?.categoryBitMask = enemyCategory
enemy.physicsBody?.contactTestBitMask = playerCategory
enemy.physicsBody?.collisionBitMask = 0
enemy.name = "enemy"
enemy.physicsBody?.usesPreciseCollisionDetection = true
player = SKSpriteNode(imageNamed: "player")
player.size = CGSize(width: player.size.width/3, height: player.size.height/3)
player.position = CGPoint(x: frame.size.width/4, y: frame.size.height/3)
player.zPosition = 15
player.name="player"
player.physicsBody = SKPhysicsBody(circleOfRadius: player.size.width/2)
player.physicsBody!.isDynamic = false
player.physicsBody?.usesPreciseCollisionDetection = false
self.physicsWorld.contactDelegate = self
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question