Latest 1.0.1
Homepage https://github.com/NachoSoto/NSBSpritesheetLayer
License WTFPL
Platforms ios 5.0
Authors

This projects enables you to use spritesheet images for animations under UIKit, in a similar way as you would do in Cocos2D or other game frameworks.

To start, you need to create an instance of NSBSpritesheet. You can do this, for example, by using NSBTexturePackerSpritesheetFactory by passing the parsed JSON and image generated by TexturePacker.

NSDictionary *spritesheets = [[NSBTexturePackerSpritesheetFactory factory] spritesheetsWithAnimationsData:data image:image];

The returned dictionary contains all the different animations in the spritesheet. You can now get an individual spritesheet with its name:

NSBSpritesheet *spritesheet = spritesheets[@"Animation"];

Once you have that Spritesheet object you can create the layer:

[[NSBSpritesheetLayer alloc] initWithSpritesheet:spritesheet framesPerSecond:30];

This is a subclass of CALayer, which means you can set it as a sublayer (- [CALayer addSublayer:]) or set it as your view layer (+ [UIView layerClass]).
This class has two methods - (void)animate and - (void)stop, which will render the spritesheet at the specified frames per second.

Latest podspec

{
    "name": "NSBSpritesheetLayer",
    "version": "1.0.1",
    "summary": "Spritesheet animations in UIKit.",
    "homepage": "https://github.com/NachoSoto/NSBSpritesheetLayer",
    "license": {
        "type": "WTFPL",
        "file": "LICENSE"
    },
    "authors": {
        "Nacho Soto": "[email protected]"
    },
    "source": {
        "git": "https://github.com/NachoSoto/NSBSpritesheetLayer.git",
        "tag": "v1.0.1"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source_files": "NSBSpritesheetLayer/Classes/*.{h,m}",
    "requires_arc": false,
    "ios": {
        "frameworks": [
            "UIKit",
            "CoreGraphics",
            "QuartzCore"
        ]
    }
}

Pin It on Pinterest

Share This