我有3个视图控制器,HomeVC,GameStartVC,GameOverVC。 GameStartVC在其视图中有一个视图框架,其中有一个完美的sprite工具包游戏,但是当游戏结束时它会进入GameOverVC,然后我点击再次播放按钮返回GameStartVC,甚至过渡到HomeVC然后在几次之后再次播放,这是一个巨大的滞后。
播放和播放再次是通过故事板分别从HomeVC和GameOverVC链接到GameStartVC的按钮。从GameOverVC回到HomeVC也来自故事板。从GameStartVC到GameOverVC是通过代码完成的。
deinit{}
无济于事。它被调用但滞后仍然存在。
GameStartVC文件
@IBOutlet weak var selfView: SKView!
@IBOutlet weak var scoreLabel: UILabel!
@IBOutlet weak var bottomConstraint: NSLayoutConstraint!
var scene: GameScene!
var skView: SKView!
var adMobBanner: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.feelFreeToColor()
self.initAdMobBanner()
scene = GameScene(size: self.view.bounds.size)
scene.gs = self
skView = selfView
skView.showsFPS = false
skView.showsNodeCount = false
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFill
skView.presentScene(scene)
score = 0
scoreLabel.text = "\(score)"
scoreLabel.layer.addBorder(UIRectEdge.Bottom, color: UIColor.blackColor(), thickness: 3)
}
deinit {
print("GONE")
}
GameScene文件(发生转换的touchesBegan()
内)
else {
self.playSound(Config.wrongSoundFileName)
if score > highScore {
highScore = score
NSUserDefaults.standardUserDefaults().setInteger(highScore, forKey: "HighScore")
}
let goVC = self.gs.storyboard?.instantiateViewControllerWithIdentifier("GameOverViewController") as! GameOverViewController
goVC.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.gs.presentViewController(goVC, animated: true, completion: {
self.removeAllChildren()
self.removeAllActions()
self.scene?.removeFromParent()
print("GONE")
})
}