0
任何人都可以帮助我插入我的高分标签,我不断产生错误,我已经着眼于将代码移动到viewDidAppear和viewDidLoad。使用未解决的标识符'addChild'
我刚刚开始与迅速,所以如果任何人都可以帮助,这将是伟大的。
谢谢。
import UIKit
import SpriteKit
import AVFoundation
import GameKit
class StatsViewController: UIViewController {
var highScoreLabelNode = SKLabelNode()
var highScore = NSInteger()
var highscoreDefault = NSInteger()
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
let highscoreDefault = NSUserDefaults.standardUserDefaults()
let score = highscoreDefault.valueForKey("HighScore")
highScoreLabelNode.fontName = "Helvetica-Bold"
highScoreLabelNode.position = CGPoint(x: 2.48, y: 1.17)
highScoreLabelNode.fontSize = 30
highScoreLabelNode.alpha = 0.7
highScoreLabelNode.text = "Highscore \(score)"
addChild(highScoreLabelNode) //USE OF UNRESOLVED IDENTIFIER 'ADDCHILD'
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return UIInterfaceOrientationMask.AllButUpsideDown
} else {
return UIInterfaceOrientationMask.All
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Release any cached data, images, etc that aren't in use.
}
override func prefersStatusBarHidden() -> Bool {
return true
}
}