Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GloryFish/Cocos2D-Iris-Effects
Iris-style effects for use in Cocos2D projects.
https://github.com/GloryFish/Cocos2D-Iris-Effects
Last synced: 3 months ago
JSON representation
Iris-style effects for use in Cocos2D projects.
- Host: GitHub
- URL: https://github.com/GloryFish/Cocos2D-Iris-Effects
- Owner: GloryFish
- Created: 2010-09-27T20:36:52.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-03-07T20:32:29.000Z (almost 14 years ago)
- Last Synced: 2023-03-10T23:37:33.617Z (almost 2 years ago)
- Language: Objective-C
- Homepage: http://gloryfish.org
- Size: 453 KB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.mdown
Awesome Lists containing this project
- awesome - Cocos2D-Iris-Effects - Iris-style effects for use in Cocos2D projects. (etc)
- awesome - Cocos2D-Iris-Effects - Iris-style effects for use in Cocos2D projects. (etc)
README
# Cocos2D Iris Effects
This project contains two classes which provide iris style effects for Cocos2D projects. The classes depend on the gfDrawFilledRect() and gfDrawInvertedCircle() functions contained in GFDrawingPrimitives.h.
This project has been updated to support Retina displays. (Thanks [snakewa](https://github.com/snakewa)!)
## CCTransitionIris
This is a scene transition which presents a closing iris over the outgoing scene which subsequently opens on the incoming scene. The iris shape can be customized.
### Basic usage:
CGPoint center = ccp([CCDirector sharedDirector].winSize.width / 2,
[CCDirector sharedDirector].winSize.height / 2);
CCTransition* trans = [CCTransitionIris transitionWithDuration:2.0f
scene:scene
irisPosition:center
radius:0.0f
color:ccBLACK];[[CCDirector sharedDirector] replaceScene:trans];
In this case we create a transition which will close over the outgoing scene with a circular shape. The screen will be filled entirely with black and will then open on the incoming scene.
The total duration of the closing and opening is 2 seconds.
Because we aren't using a sprite mask the transition draws the entire overlay using OpenGL calls for maximum crispness.
### Here's a more advanced example:
CGPoint center = ccp(300, 300);
CCTransition* trans = [CCTransitionIris transitionWithDuration:2.0f
scene:scene
irisPosition:center
radius:0.0f
color:ccRED
mask:@"mask-star-128.png"];[[CCDirector sharedDirector] replaceScene:trans];
Here we use an offset point for the irisPosition. We could use the location of a touch or a character on screen.
The radius is still 0, however if we wanted the iris to not close completely we could increase that value. This could be used to highlight a particular onscreen element which will carry over from one scene to another.
The mask parameter is the name of a square sprite which will be used as the opening for the iris. The mask should be fully white at the edges and fully transparent in the center for best results. The sprite will be rendered in the color specified by the color parameter.
You can supply any size sprite for the mask, however higher resolution sprites will have a crisper edge when enlarged. If you just want a circle, omit the mask parameter and the iris will be drawn using OpenGL and will look much better.
## CCSpotlight
TODO: Create spotlight
## Other info
This has been tested with Cocos2D 0.99.5 Beta 3
I'm sure this code can be improved. Can't wait to hear your suggestions and corrections.
License: http://www.cocos2d-iphone.org/wiki/doku.php/license (GNU LGPL v3 with an extension)
If you use this for anything, let me know. I'd be super stoked.