Special thanks to Ernesto Corvi and On-Core for porting all the Effects code from cocos2d-python to cocos2d-iphone.
THANK YOU!
Effects are a special kind of action. Instead of modifying normal properties like opacity, position, rotation, or scale, they modify a new kind of property: the grid property.
A grid property is like a matrix, it is a network of lines that cross each other to form a series of squares or rectangles.
These special actions render any CocosNode object (Layer, Scene, Sprite, etc.) into the grid, and you can transform the grid by moving its vertices.
There are 2 kind of grids: tiled grids and non-tiled grids. The difference is that the tiled grid is composed of individual tiles while the non-tiled grid is composed of vertices.
The following is an example of Ripple3D action, who uses a Grid3D (non-tiled) grid:and the following is an example of FadeOutTR action, who uses a TiledGrid3D (tiled) grid:
How do I use them ?
Like any other action, it is executed by the do: selector. eg:
// Create an sprite
Sprite *grossini = [Sprite spriteWithFile:@"grossini.png"];
// Tell the sprite to execute the Liquid effect
[grossini do: [Liquid actionWithWaves:4 amplitude:20 grid:ccg(10,10) duration:5]];
Liquid, like any other grid action, receives the grid parameter. You can adjust the quality of the effect by increasing the size of the grid. But it also implies less FPS.The Effects are IntervalAction actions so you can treat them like any other action. eg:
// create a Lens3D action
id lens = [Lens3D actionWithPosition:cpv(240,160) radius:240 grid:ccg(15,10) duration:8];
// create a Waved3D action
id waves = [Waves3D actionWithWaves:18 amplitude:80 grid:ccg(15,10) duration:10];
// create a sequence an repeat it forever
[grossini do: [RepeatForever actionWithAction: [Sequence actions: waves, lens, nil]]];
The following is the list of the available Grid3D (non-tiled) actions in v0.7:
The following is the list of the available TiledGrid3D (tiled) actions in v0.7:
Edit: fixed grammar errors, improved the layout




5 comments:
Great, looks like we'll be able to add some nice new effects and transitions.
I'm concerned about performance though. How much of an performance affect does turning on one of these effects have on the cocos2d update?
Hola, tal vez este no es el post mas indicado pero necesito algo de ayuda para instalar Cocos 2d ya que soy nuevo en el Mac OS, tengo la version 10.5.6 de OSX, descargue la ultima version de Cocos 2d y ya instale python 2.5 y la ultima version de pyglet, pero de ahi no se por donde continuar. Ya tengo instalado el iPhone SDK, cualquier ayuda seria de gran utilidad.
Saludos.
Mi correo es edgarr_ser@yahoo.com.mx
@mark: according to my tests, they consume some FPS, but they are very usable.
I think it depends on the game/effect/effect parameters.
and regarding the transitions, yes, I've added 6 new transitions that are using the effects.
Para Anonymous -edgarr_ser@yahoo.com.mx-:
Primero aprende a usar bien xcode. Es distinto a la mayoria de los IDE's de programacion, sin embargo muy facil de usar y rapido de aprender.
Para programar el iphone con cocos2d no necesitas python ni pyglet, pues el iphone se programa con objective-c (otra tecnologia que necesitas aprender).
Sabiendo todo esto, para poder usar cocos2d en proyectos de iphone solo basta hacer lo siguiente:
* crear un nuevo proyecto
* agregar referencias a los frameworks "opengles" y "quartzcore"
* descargar cocos2d
* agregar a tu proyecto los directorios "cocos2d" y "chipmunk" que vienen el la descarga de cocos2d
Y es todo, a partir de ahi puedes empezar a programar.
Suerte!
can any one guide me how can i make custom effects? how can i apply these effects to a portion of texture? eg face only?
Post a Comment