Twirl
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 扭曲中心位置
// 扭曲的数量
// 振幅
static Twirl* create(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude);
void Twirl::update(float time)
{
int i, j;
Vec2 c = _position;
for (i = 0; i < (_gridSize.width+1); ++i)
{
for (j = 0; j < (_gridSize.height+1); ++j)
{
Vec3 v = getOriginalVertex(Vec2(i ,j));
Vec2 avg(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
float r = avg.getLength();
float amp = 0.1f * _amplitude * _amplitudeRate;
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp;
Vec2 d(
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
v.x = c.x + d.x;
v.y = c.y + d.y;
setVertex(Vec2(i ,j), v);
}
}
}
cc.Twirl:create(2, cc.size(12,8), cc.p(size.width/2, size.height/2), 1, 2.5)
ShakyTiles3D
瓷砖晃动特效
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 晃动的范围
// z轴是否晃动
static ShakyTiles3D* create(float duration, const Size& gridSize, int range, bool shakeZ);
源码
void ShakyTiles3D::update(float /*time*/)
{
int i, j;
for (i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
{
Quad3 coords = getOriginalTile(Vec2(i, j));
// X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
coords.br.x += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.x += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.x += ( rand() % (_randrange*2) ) - _randrange;
// Y
coords.bl.y += ( rand() % (_randrange*2) ) - _randrange;
coords.br.y += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.y += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.y += ( rand() % (_randrange*2) ) - _randrange;
if (_shakeZ)
{
coords.bl.z += ( rand() % (_randrange*2) ) - _randrange;
coords.br.z += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.z += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
}
setTile(Vec2(i, j), coords);
}
}
}
示例
cc.ShakyTiles3D:create(t, cc.size(16,12), 5, false)
ShatteredTiles3D
破碎的3D瓷砖特效
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 晃动的范围
// z轴是否晃动
static ShatteredTiles3D* create(float duration, const Size& gridSize, int range, bool shatterZ);
源码
void ShatteredTiles3D::update(float /*time*/)
{
int i, j;
if (_once == false)
{
for (i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
{
Quad3 coords = getOriginalTile(Vec2(i ,j));
// X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
coords.br.x += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.x += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.x += ( rand() % (_randrange*2) ) - _randrange;
// Y
coords.bl.y += ( rand() % (_randrange*2) ) - _randrange;
coords.br.y += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.y += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.y += ( rand() % (_randrange*2) ) - _randrange;
if (_shatterZ)
{
coords.bl.z += ( rand() % (_randrange*2) ) - _randrange;
coords.br.z += ( rand() % (_randrange*2) ) - _randrange;
coords.tl.z += ( rand() % (_randrange*2) ) - _randrange;
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
}
setTile(Vec2(i, j), coords);
}
}
_once = true;
}
}
示例
cc.ShatteredTiles3D:create(t, cc.size(16,12), 5, false)
ShuffleTiles
瓷砖洗牌特效
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 随即速度基数(即会用此值作为底数来随机产生值)
static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed);
源码
void ShuffleTiles::update(float time)
{
Tile *tileArray = (Tile*)_tiles;
for (int i = 0; i < _gridSize.width; ++i)
{
for (int j = 0; j < _gridSize.height; ++j)
{
tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
placeTile(Vec2(i, j), tileArray);
++tileArray;
}
}
}
示例
local shuffle = cc.ShuffleTiles:create(t, cc.size(16,12), 25)
local shuffle_back = shuffle:reverse()
local delay = cc.DelayTime:create(2)
return cc.Sequence:create(shuffle, shuffle_back, delay)
FadeOutTRTiles、FadeOutBLTiles、FadeOutUpTiles、FadeOutDownTiles
- FadeOutTRTiles :淡出效果,从左下角到右上角
- FadeOutBLTiles :淡出效果,从右上角到左下角
- FadeOutUpTiles :折叠效果,从下到上
- FadeOutDownTiles :折叠效果,从上到下
// 时间
// 网格大小
static FadeOutTRTiles* create(float duration, const Size& gridSize);
static FadeOutBLTiles* create(float duration, const Size& gridSize);
static FadeOutUpTiles* create(float duration, const Size& gridSize);
static FadeOutDownTiles* create(float duration, const Size& gridSize);
示例
local function FadeOutTRTilesDemo(t)
local fadeout = cc.FadeOutTRTiles:create(t, cc.size(16,12))
local back = fadeout:reverse()
local delay = cc.DelayTime:create(0.5)
return cc.Sequence:create(fadeout, back, delay)
end
local function FadeOutBLTilesDemo(t)
local fadeout = cc.FadeOutBLTiles:create(t, cc.size(16,12))
local back = fadeout:reverse()
local delay = cc.DelayTime:create(0.5)
return cc.Sequence:create(fadeout, back, delay)
end
local function FadeOutUpTilesDemo(t)
local fadeout = cc.FadeOutUpTiles:create(t, cc.size(16,12))
local back = fadeout:reverse()
local delay = cc.DelayTime:create(0.5)
return cc.Sequence:create(fadeout, back, delay)
end
local function FadeOutDownTilesDemo(t)
local fadeout = cc.FadeOutDownTiles:create(t, cc.size(16,12))
local back = fadeout:reverse()
local delay = cc.DelayTime:create(0.5)
return cc.Sequence:create(fadeout, back, delay)
end
TurnOffTiles
方块消失特效
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
static TurnOffTiles* create(float duration, const Size& gridSize);
// seed 随即速度基数(即会用此值作为底数来随机产生值)
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
示例
local function TurnOffTilesDemo(t)
local fadeout = cc.TurnOffTiles:create(t, cc.size(48,32), 25)
local back = fadeout:reverse()
local delay = cc.DelayTime:create(0.5)
return cc.Sequence:create(fadeout, back, delay)
end
WavesTiles3D
瓷砖波浪特效
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 波动的速率
// 振幅
static WavesTiles3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
示例
local function WavesTiles3DDemo(t)
return cc.WavesTiles3D:create(t, cc.size(15,10), 4, 120)
end
JumpTiles3D
3D效果tiles跳跃
// 持续时间(时间过后不会回到原来的样子)
// 整个屏幕被分成几行几列
// 跳几下
// 振幅
static JumpTiles3D* create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude);
示例
local function JumpTiles3DDemo(t)
return cc.JumpTiles3D:create(t, cc.size(15,10), 2, 30)
end
SplitRows、SplitCols
- SplitRows 分多行消失特效
- SplitCols 分多列消失特效
// 时间
// 行数或者列数
static SplitRows* create(float duration, unsigned int rows);
static SplitCols* create(float duration, unsigned int cols);
示例
local function SplitRowsDemo(t)
return cc.SplitRows:create(t, 9)
end
local function SplitColsDemo(t)
return cc.SplitCols:create(t, 9)
end
PageTurn3D
3D翻页特效,从右下角往左上角翻
// 时间
// 网格大小
static PageTurn3D* create(float duration, const Size& gridSize);
示例
local function PageTurn3DDemo(t)
cc.Director:getInstance():setDepthTest(true)
return cc.PageTurn3D:create(t, cc.size(15,10))
end
原文地址:https://blog.csdn.net/canjiangmengyuan/article/details/134556466
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_4877.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。