我正在使用CreateJS進行遊戲。在桌面上我的FPS很不錯,但是當我嘗試在移動設備上玩這個遊戲時(例如:iPhone 4),FPS就會嚴重下降。CreateJS FPS掉落時調用stage.update
我試圖找出原因,但
一些代碼
我的畫布
<canvas id="gameCanvas"></canvas>
設置
this.canvas = "gameCanvas";
this.stage = new createjs.Stage(this.canvas);
var context = this.stage.canvas.getContext("2d");
context.imageSmoothingEnabled = false;
createjs.Ticker.setFPS(30);
this.gameLoopBind = this.gameLoop.bind(this);
createjs.Ticker.addEventListener('tick', this.gameLoopBind);
GameLoop
// some extra code
this.stage.update();
當我評論的代碼在移動/平板電腦是很好的「this.stage.update()」我的FPS ......
我不知道我做錯了什麼......
額外的代碼 玩遊戲這裏=>f.cowb.eu/mora/chick-ins
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();
};
新小吃 你可以在這裏找到創建新零食的代碼=>http://jsfiddle.net/9ofpqq3z/
在這裏,我們創建一個新的零食和動畫。
:
此外,您還可以看看下面一組關於如何使用帆布時提高移動設備的性能幻燈片除了第一幀之外沒有渲染任何東西(如果你至少在遊戲循環外調用'stage.update()'),那麼這就是爲什麼你得到FPS增加的原因。你能發佈一些更多的代碼嗎,所以我們可以看到你正在渲染的東西嗎? – 2015-03-02 18:15:18
你可以在這裏查看遊戲=> f.cowb.eu/mora/chick-ins 上面的一些額外的代碼 – 2015-03-03 08:39:27
@HaykoKoryun任何想法? – 2015-03-04 10:03:44