Git Product home page Git Product logo

ccanimatedsprite's Introduction

Note: This is a cocos2d 3.0 class and demo project. It is not compatible with cococ2d 2.x. We have a Kobold2D version on branch "kobold2d-2.x-branch"

CCAnimatedSprite

This CCSprite subclass provides a simple way of animating Sprites in cocos2d 3.0.

Usage

####Initialization: Provide a .plist file generated either Texture Packer or zwoptex.

CCAnimatedSprite *animatedSprite = [CCAnimatedSprite animatedSpriteWithPlist:@"animation_knight.plist"];

####Creating animations: Select a duration for presenting each of the animation frames and provide an animation name. This animation name needs to correspond to the names in your plist. If the animation is called animation_knight your frames in the .plist need to be called animation_knight-1.png, animation_knight-2.png and so forth:

image

[animatedSprite addAnimationwithDelayBetweenFrames:0.1f name:@"animation_knight"];

####Run animations: Simply call runAnimation and provide a name of a previously created animation. This will run the animation in a loop.

[animatedSprite runAnimation:@"animation_knight"];

####Stop animations: Straightforward:

[animatedSprite stopAnimation];

####Set a custom frame: Manually sets a frame. Does not stop any running animation. The image name needs to be contained in the plist-File which was used to initialize this CCAnimatedSprite instance.

[animatedSprite setFrame:@"animation_knight-1.png"];

####Access animation actions: If you for any reason need to perform animations manually, for example if you want to run an animation only once instead of looping it, you can use animationByName to access the CCActionAnimate objects for each animation:

// load the animation
CCActionAnimate *animation = [animatedSprite animationByName:@"animation_knight"];

// stop any current animation
[animatedSprite stopAnimation];

// run loaded animation once
[animatedSprite runAction:animation];

Sample Project

You can simply download this example project to see all the described functionality in action. image

ccanimatedsprite's People

Contributors

ben-g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ccanimatedsprite's Issues

license

The current license ("Copyright (c) 2013 MakeGamesWithUs. All rights reserved.") is potentially problematic. Might you consider one that would more clearly make this code available for others to use? Thanks for this and your other valuable work.

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.