Hub

AnimatePacker

Thumb_animatepacker-icon
  • Name:AnimatePacker
  • Author:Goldlion
  • Code Repository:
  • Last Update:2013-04-08
  • Compatible with:2.0
  • Platform:IOS, Android
  • API Language:C++
  • Website:
  • Company:

Brief

AnimatePacker is a tool to simplify the process of adding sprites into SpriteFrames for CCAnimate, running on Windows

Description

h3.Latest Update on 2012-6-17

  • To save memory, AnimatePacker support “Trim” and “Allow rotation” features in TexturePacker.
  • Support cocos2d-x 2.0

Using the Tool

You should use AnimationPacker together with the plist file generated by TexturePacker. The steps to use AnimationPacker are:
# Drag and drop the plist files into the window of AnimationPacker
# Click camera icon to generate a new animation, then edit “Name” and “Delay” field in animations reagion
# Drag sprites into SpriteFrames. Dragging SpriteFrame to reorder them.
# At the end, click “Save” and get your own xml file.

Parsing its output xml file

At first, you need these 3 files to be involved in your project
* AnimationPacker.h
* AnimationPacker.cpp
* Singleton.h

The parsing code is very simple, with only 2 interfaces:

void AnimatePacker::loadAnimate(char *path); // Loading the animate in outputted xml file
cocos2d::CCAnimate* AnimatePacker::getAnimate(char *name); // get animate from by a particular name

The usage looks like this:

AnimatePacker::getInstance()->loadAnimate("1111.xml"); 
CCSprite *sprite=CCSprite::spriteWithSpriteFrameName("bomb_dead0.png"); 
sprite->setAnchorPoint(CCPointZero); 
sprite->setPosition(ccp(size.width/2, size.height/2)); 
sprite->runAction(CCRepeatForever::actionWithAction(AnimatePacker::getInstance()->getAnimate("aaa"))); 
addChild(sprite,1); 

Downloads:

Comments

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.