小桑博客

如果渡不过这不可渡的海,将成为这海中捞不起的沙

[Cocos2d-x wiki翻译]Effects

Effects

介绍

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.

Effect是特殊类型的动作.与修改常规的属性如透明度、位置、旋转或缩放等不同,它们修改的是一种新类型的属性:grid属性.

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.

grid属性像是一个矩阵,是由相互交叉形成一系列正方形和矩形的线组成的网络。

These special actions render any CocosNode object (Layer, Scene, Sprite, etc.) into the grid, and you can transform the grid by moving its vertices.

这些特殊的动作可以渲染任一CocosNode对象 (Layer, Scene, Sprite, 等.)到grid中,你可以通过顶点来变换grid.

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.

一共有2类grid: 瓦片grid(tiled grids)和非瓦片grid(non-tiled grids).它们的区别在于瓦片grid是由独立的瓦片(tile)组成,而非瓦片grid由顶点组成。

The following is an example of Ripple3D action, who uses a Grid3D (non-tiled) grid:

下面是Ripple3D动作例子,它使用的是 Grid3D (非瓦片的) grid:

and the following is an example of FadeOutTR action, who uses a TiledGrid3D (tiled) grid:

接下来是FadeOutTR动作例子,它用的是TiledGrid3D (瓦片) grid:

用法

Like any other action, it is executed by the runAction. eg:

和其他动作一样,是通过runAction执行的.例如:

1
2
3
// Create an sprite
CCSprite* grossini = CCSprite::create("grossini.png");
grossini->runAction(CCLiquid::create(4, 20, ccg(10,10), 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:

和其他grid动作一样,Liquid会接收一个grid参数.你可以通过增加grid的大小来调整effect(效果)的品质.但是它也意味着有很少的FPS.
Effect是IntervalAction动作(延时动作),所以你可以用像其他动作的处理方式一样来处理它们.例如:

1
2
3
4
5
6
7
8
// create a Lens3D action
CCActionInterval* lens = CCLens3D::create(ccp(240,160),240,ccg(15,10),8);

// create a Waved3D action
CCActionInterval* waves = CCWaves3D::create(18,80,ccg(15,10),10);

// create a sequence an repeat it forever
grossini->runAction(CCRepeatForever::create((CCSequence*)CCSequence::create(waves, lens, NULL ) ) );
The following is the list of the available Grid3D (non-tiled) actions in v2.1.0:

下面是v2.1.0版本中Grid3D(non-tiled) actions的可用列表:

Shaky3D Waves3D FlipX3D FlipY3D
Lens3D Liquid Waves Twirl
Ripple3D
|
The following is the list of the available TiledGrid3D (tiled) actions

下面是TiledGrid3D(tiled) 动作可用的列表:

ShakyTiles3D ShatteredTiles3D ShuffleTiles FadeOutTRTiles
FadeOutBLTiles FadeOutUpTiles FadeOutDownTiles TurnOffTiles
WavesTiles3D JumpTiles3D SplitRows SplitCols

参考

cocos2d-iphone cocos2d’s effects简介

Comments