Post

Replies

Boosts

Views

Activity

Reply to what does this mean?!? "Argument passed to call that takes no arguments"
it kind worked and i dont know if youll be able to help but now its saying Referencing instance method 'randomElement()' on 'ClosedRange' requires that 'CGFloat.Stride' (aka 'CGFloat') conform to 'SignedInteger' Requirement from conditional conformance of 'ClosedRange' to 'Collection' (Swift.ClosedRange) this is the code with the problem let randomXStart = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.minX let randomXEnd = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.maxX help this is all the code func spawnEnemy (){ print("Start spawn") let randomXStart = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.minX let randomXEnd = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.maxX let startPoint = CGPoint(x: randomXStart, y: self.size.height * 1.2) let endPoint = CGPoint(x: randomXEnd, y: -self.size.height * 0.2) let dino = SKSpriteNode(imageNamed: "BlueDino") dino.setScale(1) dino.position = startPoint dino.zPosition = 2 self.addChild(dino) let moveDino = SKAction.moveTo(endPoint, duration: 1.5) let deleteDino = SKAction.removeFromParent() let dinoSequence = SKAction.sequence([moveDino, deleteDino]) dino.run(dinoSequence) let dx = endPoint.x - startPoint.x let dy = endPoint.y - startPoint.y let amountToRotate = atan2(dy, dx) print("dx", dx, "dy", dy, "rotation", amountToRotate) dino.zRotation = amountToRotate
Topic: App & System Services SubTopic: General Tags:
Feb ’24
Reply to Spawn Enemy Code Not working
it kind worked and i dont know if youll be able to help but now its saying Referencing instance method 'randomElement()' on 'ClosedRange' requires that 'CGFloat.Stride' (aka 'CGFloat') conform to 'SignedInteger' Requirement from conditional conformance of 'ClosedRange' to 'Collection' (Swift.ClosedRange) this is the code with the problem let randomXStart = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.minX let randomXEnd = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.maxX help this is all the code func spawnEnemy (){ print("Start spawn") let randomXStart = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.minX let randomXEnd = (gameArea.minX...gameArea.maxX).randomElement() ?? gameArea.maxX let startPoint = CGPoint(x: randomXStart, y: self.size.height * 1.2) let endPoint = CGPoint(x: randomXEnd, y: -self.size.height * 0.2) let dino = SKSpriteNode(imageNamed: "BlueDino") dino.setScale(1) dino.position = startPoint dino.zPosition = 2 self.addChild(dino) let moveDino = SKAction.moveTo(endPoint, duration: 1.5) let deleteDino = SKAction.removeFromParent() let dinoSequence = SKAction.sequence([moveDino, deleteDino]) dino.run(dinoSequence) let dx = endPoint.x - startPoint.x let dy = endPoint.y - startPoint.y let amountToRotate = atan2(dy, dx) print("dx", dx, "dy", dy, "rotation", amountToRotate) dino.zRotation = amountToRotate
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’24
Reply to I am using a font file
var gameScore = 0 let scoreLabel = SKLabelNode(fontNamed: "herculanumRegular") override func didMove(to view: SKView) { scoreLabel.text = "Score: 0" scoreLabel.fontSize = 70 scoreLabel.fontColor = SKColor.white scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.left scoreLabel.position = CGPoint(x: self.size.width0.20, y: self.size.height0.9) scoreLabel.zPosition = 100 self.addChild(scoreLabel) } func addScore(){ gameScore += 1 scoreLabel.text = "Score: (gameScore) " }
Feb ’24