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翻页特效,从右下角往左上角翻
文章来源:https://www.toymoban.com/news/detail-754934.html
// 时间
// 网格大小
static PageTurn3D* create(float duration, const Size& gridSize);
示例文章来源地址https://www.toymoban.com/news/detail-754934.html
local function PageTurn3DDemo(t)
cc.Director:getInstance():setDepthTest(true)
return cc.PageTurn3D:create(t, cc.size(15,10))
end
到了这里,关于cocos2dx Animate3D(二)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!