Giter VIP home page Giter VIP logo

cinder-pospritesheet's Introduction

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

cinder-pospritesheet's People

Contributors

bruzed avatar vtron avatar tamarziv avatar claybudin avatar jenniferpresto avatar peterobbin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.