抱歉我的英文不好。所以,在使用Android Studio和Webview制作的移动游戏中,我大约有30fps。我使用的框架是Phaser 3。我决定进行简单的测试。我删除了所有代码,只留下在指针松开事件中显示game.loop.actualfps的代码。我也从加载器中删除了所有精灵。单击屏幕时,我得到了约35fps,这很奇怪,因为只有4行代码。当我将fps显示放入更新函数中时,我得到了20fps。我要补充一点,在电脑上几乎始终有60fps。
如果我将代码替换为使用Phaser 2制作的旧游戏,则可以达到50-60fps。 Phaser 3优化不良吗?以下是我的boot.js文件代码:
如果我将代码替换为使用Phaser 2制作的旧游戏,则可以达到50-60fps。 Phaser 3优化不良吗?以下是我的boot.js文件代码:
let newWidth; let newHeight
function calculateDimensions(){
const targetWidth = 480;
const targetHeight =854;
const deviceRatio = (window.innerWidth/window.innerHeight);
const newRatio = (targetHeight/targetWidth)*deviceRatio;
newWidth = targetWidth;
newHeight = targetHeight*newRatio;
}
calculateDimensions();
const gameWidth = newWidth; const gameHeight = newHeight;
const config = {
type: Phaser.AUTO,
width:gameWidth,
heigth: gameHeight,
scale: {
mode:Phaser.Scale.ENVELOP,
autoCenter: Phaser.Scale.CENTER_BOTH
},
physics: {
default: 'arcade',
arcade: {
tileBias:8,
debug:false,
gravity: false
},
render: {
pixelArt: true
}
},
scene: [
preloader,loader,menu,
levelSelect,levelAlert,
shop,
winMenu,loseMenu,
level
]
};
window.onload = () => {
game = new Phaser.Game(config);
}
我尝试将类型从自动更改为画布和WebGL,但没有任何帮助。 我知道这些全局变量很糟糕,但现在不是重点:D。 我还可以检查什么,这些延迟的原因可能是什么? 请帮帮我。