Post

Replies

Boosts

Views

Activity

iPhone Simulator, SpriteKit
Hello everyone, does anyone know how to fix this problem? When I run iPhone simulator, physics for sprites and touches doesn't work, however on real device everything is fine. Also the error still appears: Immutable value 'touch' was never used; consider replacing with '_' or removing it import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate {       var knife = SKSpriteNode(imageNamed: "knife")   var target = SKSpriteNode(imageNamed: "target")       override func didMove(to view: SKView) {     physicsBody = SKPhysicsBody(edgeLoopFrom: frame)     physicsWorld.contactDelegate = self           spawnKnife()     spawnTarget()   }       func spawnKnife() {     knife.texture?.filteringMode = .nearest     knife.size = CGSize(width: 256, height: 256)     knife.position = CGPoint(x: 0, y: UIScreen.main.bounds.minY - 300)     knife.physicsBody = SKPhysicsBody(texture: knife.texture!, size: knife.size)     knife.physicsBody?.isDynamic = true           addChild(knife)   }       func spawnTarget() {     target.texture?.filteringMode = .nearest     target.size = CGSize(width: 512, height: 256)     target.position = CGPoint(x: 0, y: UIScreen.main.bounds.maxY - 128)     target.physicsBody = SKPhysicsBody(texture: target.texture!, size: target.size)     target.physicsBody?.isDynamic = false           addChild(target)   }       override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {     for touch in touches {       knife.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 1000))     }   }
0
0
942
Sep ’20