Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

Window.requestAnimFrame 消耗很大

$
0
0

@gaofei_dev 写道:

用profiler分析发现 CCGame.js

//Run game.
_runMainLoop: function () {
var self = this, callback, config = self.config, CONFIG_KEY = self.CONFIG_KEY,
director = cc.director;

    director.setDisplayStats(config[CONFIG_KEY.showFPS]);

    callback = function () {
        if (!self._paused) {
            director.mainLoop();
            if(self._intervalId)
                window.cancelAnimationFrame(self._intervalId);
            self._intervalId = window.requestAnimFrame(callback);
        }
    };

    window.requestAnimFrame(callback);
    self._paused = false;
},

//////////////////////////////////////
window.requestAnimFrame(callback); 这行的开销占据了95%以上,有何优化办法?

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>