Talking about Game development, HTML5, Javascript and Phaser.
If you played my latest HTML game Just Jump on your mobile device before January 5, you surely noticed the game was really really slow. As a Phaser enthusiast, I was a little concerned about this because I like to code with Phaser and I was wondering why a simple game like Just Jump was lagging that bad. I tried to remove as much code as possible from update function, as it’s executed at each frame, but nothing changed. Tried to remove ARCADE physics but nothing changed, the framerate was ridiculously slow. Until… if you read the original blog post about the game, I wrote: « The game has only one graphic asset, a small 64 x 64 pixels PNG white square. Everything, from background walls to particles, from the player to size-changing obstacles, has been made starting from that single image » Having just one graphic asset, I made large use of tileSprites, and this practice caused the problem. So I changed all tileSprites to sprites, by modifying the code from:
var spike = game.add.tileSprite((floor % 2 == 0) ? gameOptions.floorWidth + gameOptions.floorX : gameOptions.floorX, gameOptions.floorY[floor], game.rnd.integerInRange(1, 16) * 2, 40, "tile");
var spike = game.add.sprite((floor % 2 == 0) ? gameOptions.floorWidth + gameOptions.floorX : gameOptions.floorX, gameOptions.floorY[floor], "tile");
spike.width = game.rnd.integerInRange(1, 16) * 2;
spike.height = 40;
Using tileSprites | Using sprites adjusting width and height |
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.