Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the common reasons for slow down of games made with phaser for 2-3 seconds in the middle of game play?

I wrote a game for desktop using phaser, i had followed all their guidelines regarding memory free & object destruction after completion of a state but i can't understand why the game is giving jerks for 2-3 seconds each time during the entire game play(especially the tile sprite), i want to know what might be the other reasons?

like image 678
caesar getit Avatar asked Oct 31 '25 02:10

caesar getit


2 Answers

from my Experience there are few things i noticed that it makes phaser game slow specially on mobile devices .

tileSprit : as you mention it is very slow and to be honest i don't know why but i create a blank game and tested it FPS = 60 , then i draw tile sprite simple tile

game.add.tileSprite(0,0,worldWidth , worldHeight , key); 

FPS = 30 !

so i replaced it with one big sprite and tested it FPS = 45 to 50 ! it is ok i can live with that .

bitmap font : is also heavy don't use it a lot

loop inside update function is also drop the fps .

p2 physic : calling a lot of collide function and a lot of bodies (destroy the physic body as son as you done with it )

particle system : simple particle also Reduce the FPS more than 10

phaser is nice and easy but performance part need a lot of work .

EDIT

i tested Pixi for tile sprite and it is fast like Leopard FPS = 60 and sometimes more than that i will recommend using pixi tile sprite .

like image 133
Sky Walker Avatar answered Nov 04 '25 20:11

Sky Walker


Profile it using Chrome and see. If it's a function, that will show it. If it's lagging while rendering, it will show spikes during paint operations. It could be anything though - garbage collection, audio decoding (a common hidden frame rate killer), things you thought were destroyed but weren't really, excessive texture loads on the GPU and so on.

like image 45
PhotonStorm Avatar answered Nov 04 '25 20:11

PhotonStorm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!