Skip to content

Potion/Cinder-poSpritesheet

develop
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

Cinder-poSpritesheet

Potion's spritesheet block for Cinder. Cinder-poSpritesheet is released under the BSD New License.

Using this Repo

When pulling down the repo, develop is the latest branch, master is stable. If you're using in conjunction with poScene, make sure you're on poScene v2. If you're on poScene v1, you can check out the v1.0 tag. If you're on an old project with Cinder 0.8.6, you can checkout the v0.8.6 tag.

Using the Block

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