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));// Xcoords.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;// Ycoords.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));// Xcoords.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;// Ycoords.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)
endlocal 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)
endlocal 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)
endlocal 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)
endlocal 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