Nothing is visible on stage in SpriteKit

I wanted to create a game in Xcode 7.2. I wanted to create an information screen that will be inside. But nothing appears on the newly created scene. No matter what I get on a new scene, like images, sprites, labels. When I start it, nothing appears on the screen. But the code I wrote to create the shortcut works fine in the "GameScene" that the game originally contains.

The code I entered in InfoScene looks like this:

import SpriteKit

class InfoScene: SKScene {

override func didMoveToView(view: SKView) {
  let thanksLabel = SKLabelNode(fontNamed:"Arial")

  thanksLabel.text = "Thank you for Playing!"

  thanksLabel.fontSize = 45

  thanksLabel.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame))

  self.addChild(thanksLabel)
}

}

Nothing seems wrong to me. If I put the above code in the GameScene that the template originally had, a label will appear. In addition, if I add a sprite to the scene, it will not appear either. It really bothers me.

+4
2

, , :

Swift 2.x:

override func didMoveToView(view: SKView) {
  // put your stuff here
}

Swift 3.x:

override func didMove(to view: SKView){
  // put your stuff here
}

didMove , ​​. .


: ( ):

, InfoScene - . , InfoScene didMoveToView :

print("∙ \(type(of: self))")
+3

, InfoScene? ? SKS? , " ", InfoScene, SKScene

+1

Source: https://habr.com/ru/post/1662492/


All Articles