Skip to content

How to use Texture Atlas with TexturePacker

Olivier Biot edited this page Sep 26, 2015 · 41 revisions

[WIP]

featurecarousel_texturepacker

Using a texture Atlas will generally allow you to :

  • save memory, by packing all your sprites into a single texture
  • increase your framerate, by optimising the GPU usage
  • make your game starts faster, by loading a single texture

In this tutorial we are gonna to see how to :

  • use TexturePacker to create a texture atlas
  • import the generated texture into a melonJS project
  • add a static sprite
  • add an animation

create a Texture atlas

To create a new texture atlas, simply start TexturePacker and select the generic JSON (Array) framework : create new project

imported files

Recommended settings :

  • use "Power of Two" size for the texture, to optimize the use of GPU memory
  • we recommend not to use texture rotation when possible (although this will increase the final texture size), as it forces melonJS to apply a default rotation angle when drawing sprites and, based on how many sprites are to be displayed, can impact performance.

melonJS boilerplate

add the static background

add the cap guy animation

source code

https://github.com/melonjs/melonJS/tree/master/examples/texturepacker

Clone this wiki locally