sorry for poor english. So, I have about 30fps in my mobile game made with android studio, using webview. The framework I use is phaser 3. I decided to make a simple test. I removed all the code and left, on pointer up event which is showing game.loop.actualfps. I have removed all sprites from loader too. Clicking on screen I have about 35fps which is weird with only 4 lines of code. When i put fps display in update function i had 20fps. I will add that on the puter there is almost constant 60fps.
If I replace the code to my old game made with phaser 2 i have 50-60fps. Is phaser 3 poorly optimized? Here is my boot.js file code:
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);
}
I tried changing the type from auto to canvas and webgl. Nothing helped. I know these global variables are bad, but that's not the point now :D. What else can I check and what could be the reason for these lags? please help.
sorry for poor english. So, I have about 30fps in my mobile game made with android studio, using webview. The framework I use is phaser 3. I decided to make a simple test. I removed all the code and left, on pointer up event which is showing game.loop.actualfps. I have removed all sprites from loader too. Clicking on screen I have about 35fps which is weird with only 4 lines of code. When i put fps display in update function i had 20fps. I will add that on the puter there is almost constant 60fps.
If I replace the code to my old game made with phaser 2 i have 50-60fps. Is phaser 3 poorly optimized? Here is my boot.js file code:
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);
}
I tried changing the type from auto to canvas and webgl. Nothing helped. I know these global variables are bad, but that's not the point now :D. What else can I check and what could be the reason for these lags? please help.
Share Improve this question edited Feb 17, 2020 at 2:46 James Skemp 8,6019 gold badges70 silver badges112 bronze badges asked Dec 23, 2019 at 19:06 sidsonpatricksidsonpatrick 331 silver badge5 bronze badges 1- Please someone help i tried everything. Deleted everthing and still 40 fps with pure phaser – sidsonpatrick Commented Dec 23, 2019 at 21:18
2 Answers
Reset to default 3Webview is really slow on some devices. Try to disable physics (and replace it with your custom code if that helps).
From my experience moving to cordova and using webgl really helps a lot. Some devices will start to work as expected if you add isGame:true to the app config.
The really last step you could try is moving webview to custom one (for cordova that would be xwalk or crosswalk plugin), that will significantly increase the size of application (~60Mb) but forces it to work as expected on much wider list of devices.
I'm probably a bit late, but if you're reading this, try adding "powerPreference":"high-performance" into the game config.
TLDR:
new Phaser.Game({powerPreference:"high-performance",...})
It gives a fair performance boost, at least in Google Chrome.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745376087a4625004.html
评论列表(0条)