Reputation: 145
I'm beginner in Swift
and SpriteKit
.
I have gameViewController
with code:
if let scene = IntroScene(fileNamed:"IntroScene") {
// Configure the view.
let skView = self.view as! SKView
skView.showsFPS = true
skView.showsNodeCount = true
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
}
My app starting with this scene. I have some code with simple animation for this scene in other viewController:
let introAnimationFadeIn = SKAction.fadeInWithDuration(0.05)
let introAnimation = SKAction.animateWithTextures([introAnimation1, introAnimation2, introAnimation3, introAnimation4, introAnimation5], timePerFrame: 1.5)
let sequenceIntroAnimation = SKAction.sequence([
introAnimationFadeIn,
introAnimation])
intro.runAction(sequenceIntroAnimation)
GameScene
after animation complete?GameScene
, when SKSpriteNode
touched? Or create button would be better?
I know that segue can be only with viewControllers
, but I don't know how names segues between game scenes correct. And sorry for my English.Upvotes: 1
Views: 101
Reputation: 274835
If you want to go from one scene to another, you don't use segues. Segues are transitions between view controllers, not SKScene
s.
To present another scene, just get an SKView
and call presentScene
!
let scene = YourSceneClass(fileNamed:"Name of your scene that is going to present")!
view.presentScene(scene) // view is an SKView
And it seems like you want to do an animation before presenting the scene. You don't need SKAction
s for this. Why not use SKTransition
instead?
You can use this code to transition to another scene with fade:
// again, view is an SKView
view.presentScene(scene, transition: SKTransition.fadeWithDuration(1))
Easy as that!
Upvotes: 3