Getting started: TexturePacker and Cocos2d-x

This overview shows you how to create your first sprite sheet and import it into your cocos2d-x project.

These easy steps will cost you only 5 minutes - but make your development much easier. Promised!

1.
Open TexturePacker, select cocos2d as framework.

TexturePacker: Select cocos2d as framework

2.
Add sprites ...

Drag & drop sprites
onto TexturePacker.


... or folders

TexturePacker adds
all sprites inside the folder
and updates the texture
when the content changes.

Add Sprites to TexturePacker

3.
Set output files
Make sure to set the output path of both files so that the images can be reached from your project.

Set the output path for your files

4.
Click Publish sprite sheet to write the sprite sheet to your Cocos2D-X project.

TexturePacker: Click Publish sprite sheet

5.
Add texture and plist file to your project.

Add files to your cocos2d-x project

6.
Load texture data

SpriteFrameCache* cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("spritesheet.plist");

7.
Create sprites

Use the sprite directly

Sprite *sprite = Sprite::createWithSpriteFrameName("object.png");
parent->addChild(sprite);

Or use a sprite batch node for faster rendering

SpriteBatchNode* spritebatch = SpriteBatchNode::create("spritesheet.png");
parent->addChild(spritebatch);

Sprite *sprite = Sprite::createWithSpriteFrameName("object.png");
spritebatch->addChild(sprite);

Do you want to read more?

Head over to our Cocos2D-X tutorials section.

Do you have any feedback or questions?