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!

Open TexturePacker, select cocos2d as framework.

TexturePacker: Select cocos2d as framework

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

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

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

TexturePacker: Click Publish sprite sheet

Add texture and plist file to your project.

Add files to your cocos2d-x project

Load texture data

SpriteFrameCache* cache = SpriteFrameCache::getInstance();

Create sprites

Use the sprite directly

Sprite *sprite = Sprite::createWithSpriteFrameName("object.png");

Or use a sprite batch node for faster rendering

SpriteBatchNode* spritebatch = SpriteBatchNode::create("spritesheet.png");

Sprite *sprite = Sprite::createWithSpriteFrameName("object.png");

Do you want to read more?

Head over to our Cocos2D-X tutorials section.

Do you have any feedback or questions?

By clicking 'Submit' you agree that the data entered above is sent to and stored by CodeAndWeb GmbH for the purpose of answering your request. The data is transmitted through an encrypted internet connection and processed according to our privacy policy. You can withdraw your consent at any time with effect for the future.