#Cinder-poSpritesheet
Potion's spritesheet block for Cinder. Cinder-poSpritesheet is released under the BSD New License.
The block consists of two classes:
- Spritesheet: parses and keeps track of the frame data
- SpritesheetAnimation: provides control for frame playback
Tested on OS X Yosemite and Windows 8.
- Supports spritesheets created with TexturePacker
- JSON (Array), XML (generic) data formats from within TexturePacker
- Multipacked textures
- Play, pause, stop, loop, reverse animation
- Set animation frame rate
- Get signal when animation has finished playing
Currently doesn't support rotated sprites.
- SpritesheetFrame: draws a spritesheet frame based on mouse position
- SpritesheetAnimation: animates spritesheet frames across the app window
goblin by Clint Bellanger used under Creative Commons Attribution (CC-BY) 3.0 License / Scaled up from original.
To draw a specific frame from the spritesheet:
gl::TextureRef texture = gl::Texture::create(loadImage(loadAsset("goblin.png")));
JsonTree json = JsonTree(loadAsset("goblin.json"));
mSpritesheet = po::Spritesheet::create(texture, json);
// draw frame by number
mSpritesheet->drawFrame(6);
// frame by source filename
mSpritesheet->drawFrame("0031.png");
To animate the spritesheet:
gl::TextureRef texture = gl::Texture::create(loadImage(loadAsset("charge.png")));
JsonTree json = JsonTree(loadAsset("charge.json"));
mSpritesheet = po::Spritesheet::create(texture, json);
mSpritesheetAnimation = po::SpritesheetAnimation::create(mSpritesheet);
mSpritesheetAnimation->play();