Sprite class for Cocos2d that supports a shattered effect.
Cocos2d-swift v3 dropped support for the shatter effect action, so this class was created to support for a shattered effect. The code originally started from this example for Cocos2d v2, but has been heavily modified.
ShatteredSprite is a subclass of Sprite, so you can use it just like a regular sprite.
The below code shows allocation of a ShatteredSprite, then shattering the sprite in to 35 pieces.
ShatteredSprite* shatteredSprite = [ShatteredSprite spriteWithFile:@"smile.png"];
[shatteredSprite shatterWithPiecesX:5 withPiecesY:7 withSpeed:0.5 withRotation:0.02];
To end the shattered effect, you can call the reset method and the sprite will reset to normal.
[shatteredSprite reset];
Currently there isn't support to use effect shaders while the shattered effect is running.
You need to be using Cocos2d-swift v3.
Copyright (C) 2015 Duncan Cunningham
Distributed under the MIT License.