我正在制作一个游戏,想要实现场景过渡。然而,在使用场景过渡时出现了以下错误:
[Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once. 3fatal error: unexpectedly found nil while unwrapping an Optional value 2017-01-09 16:58:33.716407 MyGameApp[18371:5784169] fatal error: unexpectedly found nil while unwrapping an Optional value 有人知道是怎么回事吗?
这是我的代码:
错误:
[Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once. 3fatal error: unexpectedly found nil while unwrapping an Optional value 2017-01-09 16:58:33.716407 MyGameApp[18371:5784169] fatal error: unexpectedly found nil while unwrapping an Optional value 有人知道是怎么回事吗?
这是我的代码:
import UIKit
import SpriteKit
class Congrats: SKScene {
override func didMove(to view: SKView) {
backgroundColor = UIColor(red: CGFloat(248), green: CGFloat(248), blue: CGFloat(248), alpha: CGFloat(255)) //SKColor
var message = "Good Job! "
let label = SKLabelNode(fontNamed: "AppleSDGothicNeo-Bold")
label.text = message
label.fontSize = 22
label.fontColor = SKColor.blue
self.backgroundColor = SKColor.black
label.position = CGPoint(x: size.width / 2, y: size.height / 2)
addChild(label)
run(SKAction.sequence([
SKAction.wait(forDuration: 1.0),
SKAction.run() {
let reveal = SKTransition.flipHorizontal(withDuration: 1.0)
let scene = GameOver(size: (self.view?.frame.size)!)
self.view?.presentScene(scene, transition:reveal)
}
]))
-----
错误:
![](https://istack.dev59.com/3JCh3.webp)
触碰变量
if countTouch > 10 {
for touch: AnyObject in touches {
let skView = self.view! as SKView
skView.ignoresSiblingOrder = true
var scene: Congrats!
scene = Congrats(size: skView.bounds.size)
scene.scaleMode = .aspectFill
skView.presentScene(scene, transition: SKTransition.doorsOpenHorizontal(withDuration: 1.0))
}
}
OR 这个错误。有人能检查一下吗。
if firstTouch {
shownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(MyNewGame.decTimer), userInfo: nil, repeats: true)
gameTimer = Timer.scheduledTimer(timeInterval: TIME_INCREMENT, target:self, selector: Selector("endGame"), userInfo: nil, repeats: false)
firstTouch = false
}
PS: 我正在制作一个玩家/用户触摸粒子的游戏,当他们达到限制时,我想过渡到祝贺场景。有人可以检查我是否做对了吗?我认为这是崩溃的原因。
这也是崩溃时的错误代码:
0_specialized _fatalerrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never