本文总结一些带网格的3D特效的用法。
1、Shaky3D(晃动特效)、ShakyTiles3D(瓷砖晃动特效)
ShakyTiles3D参数及用法与Shaky3D一模一样的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/**
* 创建一个3D晃动的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* range : 晃动的范围
* shakeZ : z轴是否晃动
* 看源码晃动范围range为网格的上的位置:
for (i = 0; i < (_gridSize.width+1); ++i)
{
for (j = 0; j < (_gridSize.height+1); ++j)
{
Vertex3F v = getOriginalVertex(Vec2(i ,j));
v.x += (rand() % (_randrange*2)) - _randrange;
v.y += (rand() % (_randrange*2)) - _randrange;
if (_shakeZ)
{
v.z += (rand() % (_randrange*2)) - _randrange;
}
setVertex(Point(i, j), v);
}
}
*/
/** creates the action with a range, shake Z vertices, a grid and duration */
static
Shaky3D* create(
float
duration,
const
Size& gridSize,
int
range,
bool
shakeZ);
|
2、Waves3D(波浪特效)、WavesTiles3D(瓷砖波浪特效)、Waves(带方向的波浪特效,水平与垂直)
WavesTiles3D参数及用法与Waves3D一模一样的。
1
2
3
4
5
6
7
8
9
|
/**
* 创建一个3D波浪的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* waves :波动的速率
* amplitude :振幅
*/
/** creates an action with duration, grid size, waves and amplitude */
static
Waves3D* create(
float
duration,
const
Size& gridSize, unsigned
int
waves,
float
amplitude);
|
Waves的参数说明
1
2
3
4
5
6
7
8
9
10
|
/**
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* waves :波动的速率
* amplitude :振幅
* horizontal :是否是水平方向
* vertical :是否是垂直方向
*/
/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
static
Waves* create(
float
duration,
const
Size& gridSize, unsigned
int
waves,
float
amplitude,
bool
horizontal,
bool
vertical);
|
3、FlipX3D(X轴翻转动画)、FlipY3D(Y轴翻转动画)
FlipX3D与FlipY3D一样,给一个时间单位,在此时间内绕X轴或Y轴旋转。
1
2
3
4
5
|
/**
* 创建一个x轴翻转精灵的动画
*/
/** creates the action with duration */
static
FlipY3D* create(
float
duration);
|
4、Lens3D(凸镜特效)
1
2
3
4
5
6
7
8
9
|
/**
* 创建一个凸镜特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 网格大小
* position : 凸镜中心点
* radius : 半径
*/
/** creates the action with center position, radius, a grid size and duration */
static
Lens3D* create(
float
duration,
const
Size& gridSize,
const
Point& position,
float
radius);
|
5、Ripple3D(水波特效)
1
2
3
4
5
6
7
8
9
10
11
|
/**
* 创建一个水波特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 网格大小
* position : 凸镜中心点
* radius : 半径
* waves :波动的速率
* amplitude :振幅
*/
/** creates the action with radius, number of waves, amplitude, a grid size and duration */
static
Ripple3D* create(
float
duration,
const
Size& gridSize,
const
Point& position,
float
radius, unsigned
int
waves,
float
amplitude);
|
6、Liquid(液体特效)
和Waves3D的参数一样
1
2
3
4
5
6
7
8
9
|
/**
* 创建一个3D液体的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* waves :波动的速率
* amplitude :振幅
*/
/** creates the action with amplitude, a grid and duration */
static
Liquid* create(
float
duration,
const
Size& gridSize, unsigned
int
waves,
float
amplitude);
|
7、Twirl(扭曲旋转特效)
1
2
3
4
5
6
7
8
9
10
|
/**
* 创建一个扭曲的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* position : 扭曲中心位置
* twirls :扭曲的数量
* amplitude :振幅
*/
/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
static
Twirl* create(
float
duration,
const
Size& gridSize, Point position, unsigned
int
twirls,
float
amplitude);
|
8、ShatteredTiles3D(破碎的3D瓷砖特效)
1
2
3
4
5
6
7
8
9
|
/**
* 创建一个破碎的3D瓷砖的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* nRange : 晃动的范围
* bShatterZ : z轴是否晃动
*/
/** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */
static
ShatteredTiles3D* create(
float
duration,
const
Size& gridSize,
int
nRange,
bool
bShatterZ);
|
9、ShuffleTiles(瓷砖洗牌特效)
1
2
3
4
5
6
7
8
|
/**
* 创建一个瓷砖洗牌的特效
* duration : 持续时间(时间过后不会回到原来的样子)
* gridSize : 整个屏幕被分成几行几列
* seed : 随即速度基数(即会用此值作为底数来随机产生值)
*/
/** creates the action with a random seed, the grid size and the duration */
static
ShuffleTiles* create(
float
duration,
const
Size& gridSize, unsigned
int
seed);
|
10、FadeOutTRTiles、FadeOutBLTiles、FadeOutUpTiles、FadeOutDownTiles
-
FadeOutTRTiles :淡出效果,从左下角到右上角
-
FadeOutBLTiles :淡出效果,从右上角到左下角
-
FadeOutUpTiles :折叠效果,从下到上
-
FadeOutDownTiles :折叠效果,从上到下
他们函数参数意义一样
1
2
3
4
5
6
7
|
/**
* 淡出效果, 从左下角到右上角
* duration : 时间
* gridSize :网格大小
*/
/** creates the action with the grid size and the duration */
static
FadeOutTRTiles* create(
float
duration,
const
Size& gridSize);
|
11、TurnOffTiles(方块消失特效 )
提供了两个函数接口,多用的面一种,参数参照前面的
1
2
3
4
5
6
|
/** creates the action with the grid size and the duration */
static
TurnOffTiles* create(
float
duration,
const
Size& gridSize);
/** creates the action with a random seed, the grid size and the duration */
static
TurnOffTiles* create(
float
duration,
const
Size& gridSize, unsigned
int
seed);
|
12、SplitRows、SplitCols
-
SplitRows :分多行消失特效
-
SplitCols :分多列消失特效
1
2
3
4
5
6
7
8
9
10
|
/**
* rows : 行数
*/
SplitRows::create(
float
duration, unsigned
int
rows)
/**
* cols : 列数
*/
SplitCols::create(
float
duration, unsigned
int
cols)
|
13、PageTurn3D
1
2
3
4
5
|
PageTurn3D :3D翻页特效,从右下角往左上角翻
/**
* gridSize : 网格大小
*/
PageTurn3D::create(
float
duration,
const
cocos2d::Size &gridSize)
|