Vlad Verba
Vlad Verba

Reputation: 19

Why is my second scene empty?

I have two scenes currently. I want my first scene to transition to the second under certain standards. However it is just giving me a blank screen as my second scene. Please help :) Heres is the code that spawns the second scene:

  for touch in touches {
            let location = touch.locationInNode(self)
            if playButton.containsPoint(location) {
                self.view?.presentScene(Level2())
                plate.removeFromParent()
                sprite.removeFromParent()
            }

and here is the code I have in my second scene. It says I add a sprite but the sprite is not showing up.

import Foundation 
import SpriteKit

class Level2 : SKScene {
    var sprite :SKSpriteNode!
    override func didMoveToView(view: SKView) {

        scene?.backgroundColor = UIColor.whiteColor()
        sprite = SKSpriteNode(imageNamed: "Circle Sprite1")
        sprite.position = CGPoint(x: 350, y: 700)
        Level2().addChild(sprite)
    }
}

Upvotes: 0

Views: 51

Answers (1)

Knight0fDragon
Knight0fDragon

Reputation: 16837

This is because all you have is a blank white screen

Level2().addChild(sprite) means create a new level2 scene, and add the child sprite. You want self.addChild(sprite)

Upvotes: 1

Related Questions