我在游戏中使用了Phaser 2。最初打开游戏时,它可以在55到60 fps的情况下正常运行,但是一段时间后它会降低到fps到30以下。这是游戏的网址:http://139.59.91.216:8082/。
游戏区
game = new Phaser.Game(1366, 778, Phaser.AUTO, null);
game.state.add('Game', Game);
game.state.start('Game');
glowFilter = new Phaser.Filter.Glow(game);
在游戏的更新功能中,我正在这样做:
update: function () {
// to update the stcik lenght
for (var i = self.game.snakes.length - 1; i >= 0; i--) {
self.game.snakes[i].updateStick();
}
// to update the FoodGroup
for (var i = this.foodGroup.children.length - 1; i >= 0; i--) {
var f = this.foodGroup.children[i];
f.food.update();
}
updateAndSendData(self); // to send the data to server from client side
},
有人可以建议我如何改善游戏性能吗?