I am creating a game, and where I want to transition scenes. However, I am getting this error when using transitioning scenes:
[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
Does anyone know what is going on?
Here is my code:
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)
}
]))
-----
Touching Variable
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 This error . Can anyone check it.
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: I'm making where player/user touches on a particle and when they reached their limit, I want to transition to the Congrats scene. Can anyone check if I did this right? I believe this is the crash.
This is also the error code when it crashes:
0_specialized _fatalerrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never