A Grunt task that creates Phaser asset packs automatically.

Article by Richard Davey. Posted on 16th Aug 2016.   @phaser_


This tool helps you generate an asset pack from your filesystem directory, so that you can easily preload all your assets required for your Phaser game.

In the Phaser game engine, you can traditionally load your assets like this:

  game.load.image('kirito', 'assets/sprites/kirito_by_vali233.png');
  game.load.image('asuna', 'assets/sprites/asuna_by_vali233.png');

This is fine for just a few assets but when you need a larger amount of assets, this can become cumbersome. Phaser has the notions of asset packs. These would normally have to be edited by hand or with some authoring tool. So, what can this tool do?

  • If you just want to access things like a normal filesystem, it can generate an asset pack that you generate once at build time and then load using filesystem paths as the phaser keys.
  • It will clean up your hard-coded load codes. It will make loading assets in your game easier.
  • It will allow you to generate multiple asset packs and use them for whatever you'd like. Want to group your assets by level and then load all the level assets when the level is loaded? You can use this tool to bundle up those assets. (Hint: you would just specify a glob for each level in the files)

... basically, this lets you create those asset packs based on some rules that you define.

Read More