Introduction to effects Introduction
Effects is a special action of some columns. Compared to changing common attributes, such as transparency, position, rotation, or scaling, they modify a new attribute, grid attribute.
A grid attribute is like a matrix. It is a network line that forms a series of blocks and matrices.
These special actions change any cocosnode object (layer, scenario, Genie, etc.) into a grid. You can change them through their vertices.
There are two different grids: tiled and non-tiled grids. The difference is that tiled grids are composed by their respective tiled, while non-tiled grids are composed by vertices.
A grid has two dimensions: rows and columns. However, any vertex has three dimensions, XYZ. So you can build a 2D or 3D effect, the difference is through a tiled-grid-3d or a grid-3d.
You can increase the size of the grid to improve the effect quality, but the effect speed will decrease.
A () grid will run very fast, but it will not look very good. () Will look very good, but in the one1 generation, it will not run too fast.
How they work
Each frame the screen is rendered into a texture (FBO). This texture is transformed into a vertex array and this vertex array (the grid !) Is transformed by the grid effects. Finally the vertex array is rendered into the screen.
The frame on any screen is renamed as a texture (FBO). The texture is converted to a vertex array, which is converted by the grid effect. Finally, the vertex array is displayed on the screen.
For more information about the internals refer:
- Tiledgrid3d and tiledgrid3daction for tiled Grids
- Grid3d and grid3daction for non-tiled Grids
For example, if you have an scene or layer that renders this image:
We can convert the image to the above, using ripple3d action. just like the odd picture of your machete, you can use a 32x24 block. The grid is a non-tiled (all blocks are together)
The preceding section uses a 16x12 block and the grid is a tiled (all blocks or tiled can be separated)
3D actions 3D action
Named after 3d as their suffixes, it means that a virtual 3D effect will be generated by changing the Z axis of the grid.
If you want to use 3D actions, you may need to use the deep cache. The simple method of calling is:
// important: Call this function at the very beginning,
// before running your 1st scene
// create a depth buffer of 24 bits
// These means that OpenGL Z-order will be taken into account
[[ Director shareddirector ] setdepthbufferformat : kdepthbuffer16 ];
The following sectionCodeYou may still need to set the rgba8888 format pixel. This will produce transparent results.
// Important: Call this function at the very beginning,
// Before running your 1st scene
// Use this pixel format to have transparent Buffers
[[Director Shareddire]Setpixelformat:Krgba8];
Index of grid effects Index
Available grid3daction
AvailableGrid3daction
Actions:
- Flipx3d
- Flipy3d
- Lens3d
- Liquid
- Ripple3d
- Shaky3d
- Twirl
- Waves
- Waves3d
AvailableTiledgrid3daction
Actions:
-
Fadeoutbltiles
-
Fadeouttrtiles
-
Fadeoutuptiles
-
Fadeoutdowntiles
-
- Jumptiles3d
-
Shakytiles3d
-
Shatteredtiles3d
Shuffletiles
-
Splitcols
-
Splitrows
-
Turnofftiles
-
Wavestiles3d
Examples example
Some examples:
// Execute a waves action on sprite 1
id waves = [ waves actionwithwaves : 5 amplice : 20 horizontal : Yes vertical : NO
Grid:CCG(15,10)Duration:5];
[Sprite1Runaction:[Repeatforever Actionwithaction: Waves];
// And execute a shaky3d action on sprite 2
id shaky = [ shaky3d actionwithrange : 4 shakez : NO grid : CCG ( 15 , 10 ) duration : 5 ];
[Sprite2Runaction:[Repeatforever Actionwithaction: Shaky];