Posts Tagged ‘GBJam’

  • Pixel Perfect scaling a Phaser game

    gameboy25

    With GBJam3 just started today I tend to get asked this a lot on twitter: “How do I scale my game and keep it crisp?

    This is a perfectly valid question and is essential for games that rely on pixel art. And the answer is that there is no 100% fully cross-browser compatible solution. There are various CSS hacks and vendor prefixes you can try, but they won’t work on everything.

    However, if that was my final answer there would be no point in this blog post, right? When we created our lowrez jam game, which was a game running at a 32×32 resolution, we came up with the following approach that works much more reliably than any CSS hack. Here’s how to get it working:

    For this example I’ll assume you are making a GBJam game, so you’ve a restriction of 160 x 144 pixels. The same as the original Gameboy resolution. First create your Phaser game object:

    The important things to note here are:

    1. Use the un-scaled resolution
    2. Always use Phaser.CANVAS as the render method
    3. Give an empty string as the DOM parent (the 4th parameter)

    Once the game object is created we use a new object to hold our scaled canvas:

    Read More