SHMotionBlurSprite
Description
SHMotionBlurSprite class will function just like a normal sprite, but it will give the children a motion blur effect. You can change the blur duration in seconds with “blurDuration” and change the starting blur alpha with “blurAlpha”.
Sample
Example
//initialize a motion blur sprite with the default properties
SHMotionBlurSprite *motionBlurSprite = [SHMotionBlurSprite motionBlurSprite];
//set the blur duration to 10 seconds
motionBlurSprite.blurDuration = 10.0f;
//set the starting blur opacity to 25%
motionBlurSprite.blurAlpha = 0.25;
//set the blur duration to a negative number to set motion blur to forever
motionBlurSprite.blurDuration = SH_MOTION_BLUR_INFINITE;
motionBlurSprite.blurDuration = -1.0f;
//set the blur duration to zero to turn the motion blur off
motionBlurSprite.blurDuration = SH_MOTION_BLUR_NONE;
motionBlurSprite.blurDuration = 0;
Instructions
To add into your Sparrow project
-
Open your desired Sparrow project
Drag and drop the files into the “Groups & Files” pane
Open “Game.h”
Include the extension:
#include "SHMotionBlurSprite.h"
Save “Game.h”
To add directly into Sparrow source
-
Save the files into Sparrow's “/Classes/” directory
Navigate back one directory and open “Sparrow.xcodeproj”
Inside the “Groups & Files” pane, locate the “Display” group folder
Right click the “Display” group folder and click “Add → Existing Files..”
Navigate into the “/Classes/” directory and select “SHMotionBlurSprite.h” and “SHMotionBlurSprite.m”, then click “add”
On the next window, leave all options as default and click “add”
In the “Groups & Files” pane, Open “Sparrow.h”
At the bottom of the file, add:
#import "SHMotionBlurSprite.h"
Save “Sparrow.h”
Close “Sparrow.xcodeproj”
Source Code
Changelog
2011-01-14: First version
2011-01-15: Optimization and bug fixes
2011-03-27: fixed small warning, added property “renderTexture” so objects can be drawn to it directly if needed
Todo
Special Thanks
Daniel for the idea of how to implement a motion blur effect