Skip to content

tjoen/Cinder-poSpritesheet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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.

Features

  • 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.

Samples

  • 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.

Getting started

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();

About

Potion's spritesheet block for Cinder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 100.0%