Javascript 调用stage.update时删除CreateJS FPS

Javascript 调用stage.update时删除CreateJS FPS,javascript,html,canvas,createjs,Javascript,Html,Canvas,Createjs,我正在用CreateJS制作一个游戏。在桌面上,我的FPS很好,但当我尝试在手机上玩这个游戏(例如:iPhone4)时,FPS会严重下降 我想知道为什么,但是 一些代码 我的画布 <canvas id="gameCanvas"></canvas> 游戏圈 // some extra code this.stage.update(); 当我注释代码“this.stage.update()”时,我在手机/平板电脑上的FPS很好 我不知道我做错了什么 额外代码 在这里玩

我正在用CreateJS制作一个游戏。在桌面上,我的FPS很好,但当我尝试在手机上玩这个游戏(例如:iPhone4)时,FPS会严重下降

我想知道为什么,但是

一些代码

我的画布

 <canvas id="gameCanvas"></canvas>
游戏圈

// some extra code 
this.stage.update();
当我注释代码“this.stage.update()”时,我在手机/平板电脑上的FPS很好

我不知道我做错了什么

额外代码 在这里玩游戏=>

Gameloop函数

 Game.prototype.gameLoop = function (e) {


    if (this.running) {
        this.timer++;
        this.timer2++;

        if (this.timer2 > 30) {
            if (this.lastSnack + this.timeBewteen < this.stopwatch.seconds) {

                var height = (this.topSnack) ? 150 : 300;
                this.lastSnack = this.stopwatch.seconds;
                new Snack(this, this.timer, height);
                this.topSnack = this.topSnack ? false : true;
            }

            if (this.timer > (this.lastPostive + 300)) {
                this.lastPostive = this.timer;
                publisher.publish('showMessage',
                    this.positiveImages[Math.floor(Math.random() * this.positiveImages.length)],
                    common.lang,
                    'right');
            }
            this.timer2 = 0;
        }
    }

    this.stage.update();
};
Game.prototype.gameLoop=函数(e){
如果(这个正在运行){
这个.timer++;
这个.timer2++;
如果(this.timer2>30){
如果(this.lastSnack+this.timebeween(this.lastpositive+300)){
this.lastpositive=this.timer;
publisher.publish('showMessage',
this.positiveImages[Math.floor(Math.random()*this.positiveImages.length)],
共同语言,
"对";;
}
这一点。时间r2=0;
}
}
this.stage.update();
};
新点心 您可以在此处找到创建新零食的代码=>


在这里,我们创建了一个新的小吃,并对其进行了动画制作。

从游戏的架构来看,我建议您在单独的画布上绘制游戏元素,而不是现在所有内容都在一个画布上的方式

将不经常(或根本不需要)重画的电视部分放在一个画布上,然后将移动的元素放在单独的画布上

这将有助于提高帧速率

此外,您还可以查看以下一组幻灯片,了解如何在使用画布时提高移动设备的性能:

如果禁用
this.stage.update()
,则除了第一帧之外,您根本不会渲染任何内容(如果在游戏循环外调用
stage.update()
至少一次),因此,FPS会增加。你可以发布更多的代码,这样我们就可以准确地看到你渲染的内容了吗?你可以在这里查看游戏=>f.cowb.eu/mora/chick-ins一些额外的代码above@HaykoKoryun有什么想法吗?试着使用RAF模式,看看这个@HaykoKoryun的计时部分是否添加了这个?createjs.Ticker.timingMode=createjs.Ticker.RAF_同步;电视部件和灯光等不在画布上。因为它不会被重新绘制。每个元素在单独画布上的移动元素,还是一个画布上的所有移动元素?
 Game.prototype.gameLoop = function (e) {


    if (this.running) {
        this.timer++;
        this.timer2++;

        if (this.timer2 > 30) {
            if (this.lastSnack + this.timeBewteen < this.stopwatch.seconds) {

                var height = (this.topSnack) ? 150 : 300;
                this.lastSnack = this.stopwatch.seconds;
                new Snack(this, this.timer, height);
                this.topSnack = this.topSnack ? false : true;
            }

            if (this.timer > (this.lastPostive + 300)) {
                this.lastPostive = this.timer;
                publisher.publish('showMessage',
                    this.positiveImages[Math.floor(Math.random() * this.positiveImages.length)],
                    common.lang,
                    'right');
            }
            this.timer2 = 0;
        }
    }

    this.stage.update();
};