A
A
artshelom2018-10-27 15:55:04
iOS
artshelom, 2018-10-27 15:55:04

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

And of course at the very beginning he wrote:
self.physicsWorld.contactDelegate = self
What else is missing ?? What else is needed so that objects can interact?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question