簡體   English   中英

iOS和SpriteKit-重新啟動游戲后的低fps

[英]iOS & SpriteKit - low fps after restarting the game

我創建了一個簡單的iPhone游戲,在用戶丟失游戲后將其重定向到另一個視圖,並且可以單擊“再次開始”以再次玩。

當游戲開始時,它運行流暢且速度約為60 fps,當他松開游戲並再次開始觀看時,問題就開始了。

GameViewController.swift

override func viewDidLoad() {
        super.viewDidLoad()



        if let scene = GameScene(fileNamed:"GameScene") {
            /*
               ... some code ...
            */

            scene.gameOverFunc = gameOverScreen

            skView.presentScene(scene)
        }
    }

func gameOverScreen(){

        let skView = self.view as! SKView
        skView.presentScene(nil)

        dispatch_async(dispatch_get_main_queue()){
            self.performSegueWithIdentifier("gmov", sender: self)
        }
    }

GameScene.swift

func gameOver(){
        /*
           ... some code ...
        */

        if let gmovFunc = gameOverFunc {
            gmovFunc()
        } 

    }


override func update(currentTime: CFTimeInterval) {
        gameOver()
    }

我已經從“游戲結束”屏幕設置為GameViewController。 每個新游戲后,游戲性能都會下降。 在進入“游戲結束”屏幕之前,我是否必須銷毀SKScene實例或其他東西?

從GameOver到GameViewController的設置將創建另一個實例。 ViewController和場景的視圖。 因此,您的性能將會下降。 你需要unwind的SEGUE而不是創建與視圖控制器的新實例的performSegue

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM