cocos2dx-3.2 3DAction 一些3D特效

网格属性就像是一个个交叉形成的一系列的矩形。任何Node对象(Layer,Scene,Sprite等等)都具有这种特殊的属性,你可以通

过移动他们的顶点来变换这些网格。

有两种类型的网格:平铺的网格和非平铺的网格。他们两者的区别是平铺的网格由单个的网格组成,而非平铺的网格是由顶点组成。

继承于Grid3DAction的为非平铺网格,继承于TiledGrid3DAction的为平铺网格,自然产生的效果不同, 下面来看看都有哪些?


1、Shaky3D(晃动特效)、ShakyTiles3D(瓷砖晃动特效)

ShakyTiles3D参数及用法与Shaky3D一模一样的。

[cpp]  view plain copy
  1. /** 
  2.  * 创建一个3D晃动的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * range : 晃动的范围 
  6.  * shakeZ : z轴是否晃动 
  7.  * 看源码晃动范围range为网格的上的位置: 
  8.     for (i = 0; i < (_gridSize.width+1); ++i) 
  9.     { 
  10.         for (j = 0; j < (_gridSize.height+1); ++j) 
  11.         { 
  12.             Vertex3F v = getOriginalVertex(Vec2(i ,j)); 
  13.             v.x += (rand() % (_randrange*2)) - _randrange; 
  14.             v.y += (rand() % (_randrange*2)) - _randrange; 
  15.             if (_shakeZ) 
  16.             { 
  17.                 v.z += (rand() % (_randrange*2)) - _randrange; 
  18.             } 
  19.              
  20.             setVertex(Point(i, j), v); 
  21.         } 
  22.     } 
  23.  */  
  24. /** creates the action with a range, shake Z vertices, a grid and duration */  
  25. static Shaky3D* create(float duration, const Size& gridSize, int range, bool shakeZ);  


2、Waves3D(波浪特效)、WavesTiles3D(瓷砖波浪特效)、Waves(带方向的波浪特效,水平与垂直)

WavesTiles3D参数及用法与Waves3D一模一样的。

[cpp]  view plain copy
  1. /** 
  2.  * 创建一个3D波浪的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * waves :波动的速率 
  6.  * amplitude :振幅 
  7.  */  
  8. /** creates an action with duration, grid size, waves and amplitude */  
  9. static Waves3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);  

Waves的参数说明
[cpp]  view plain copy
  1. /** 
  2.  * duration : 持续时间(时间过后不会回到原来的样子) 
  3.  * gridSize : 整个屏幕被分成几行几列 
  4.  * waves :波动的速率 
  5.  * amplitude :振幅 
  6.  * horizontal :是否是水平方向 
  7.  * vertical :是否是垂直方向 
  8.  */  
  9. /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */  
  10. 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轴旋转。

[cpp]  view plain copy
  1. /**  
  2.  * 创建一个x轴翻转精灵的动画 
  3.  */    
  4. /** creates the action with duration */  
  5. static FlipY3D* create(float duration);  

4、Lens3D(凸镜特效)

[cpp]  view plain copy
  1. /**  
  2.  * 创建一个凸镜特效  
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 网格大小  
  5.  * position : 凸镜中心点  
  6.  * radius : 半径  
  7.  */   
  8. /** creates the action with center position, radius, a grid size and duration */  
  9. static Lens3D* create(float duration, const Size& gridSize, const Point& position, float radius);  

5、Ripple3D(水波特效)

[cpp]  view plain copy
  1. /**  
  2.  * 创建一个水波特效  
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 网格大小  
  5.  * position : 凸镜中心点  
  6.  * radius : 半径  
  7.  * waves :波动的速率 
  8.  * amplitude :振幅 
  9.  */   
  10. /** creates the action with radius, number of waves, amplitude, a grid size and duration */  
  11. static Ripple3D* create(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude);  

6、Liquid(液体特效)
和Waves3D的参数一样


[cpp]  view plain copy
  1. /** 
  2.  * 创建一个3D液体的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * waves :波动的速率 
  6.  * amplitude :振幅 
  7.  */  
  8. /** creates the action with amplitude, a grid and duration */  
  9. static Liquid* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);  

7、Twirl(扭曲旋转特效)

[cpp]  view plain copy
  1. /** 
  2.  * 创建一个扭曲的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * position : 扭曲中心位置 
  6.  * twirls :扭曲的数量 
  7.  * amplitude :振幅 
  8.  */  
  9. /** creates the action with center position, number of twirls, amplitude, a grid size and duration */  
  10. static Twirl* create(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude);  


8、ShatteredTiles3D(破碎的3D瓷砖特效)

[cpp]  view plain copy
  1. /** 
  2.  * 创建一个破碎的3D瓷砖的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * nRange : 晃动的范围 
  6.  * bShatterZ : z轴是否晃动 
  7.  */  
  8. /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */  
  9. static ShatteredTiles3D* create(float duration, const Size& gridSize, int nRange, bool bShatterZ);  


9、ShuffleTiles(瓷砖洗牌特效)
[cpp]  view plain copy
  1. /** 
  2.  * 创建一个瓷砖洗牌的特效 
  3.  * duration : 持续时间(时间过后不会回到原来的样子) 
  4.  * gridSize : 整个屏幕被分成几行几列 
  5.  * seed : 随即速度基数(即会用此值作为底数来随机产生值) 
  6.  */  
  7. /** creates the action with a random seed, the grid size and the duration */  
  8. static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed);  


9、FadeOutTRTiles、FadeOutBLTiles、FadeOutUpTiles、FadeOutDownTiles

FadeOutTRTiles :淡出效果, 从左下角到右上角

FadeOutBLTiles :淡出效果, 从右上角到左下角

FadeOutUpTiles :折叠效果, 从下到上 

FadeOutDownTiles :折叠效果 从上到下 

他们函数参数意义一样


[cpp]  view plain copy
  1. /**  
  2.  * 淡出效果, 从左下角到右上角  
  3.  * duration : 时间 
  4.  * gridSize :网格大小 
  5.  */    
  6. /** creates the action with the grid size and the duration */  
  7. static FadeOutTRTiles* create(float duration, const Size& gridSize);  


10、TurnOffTiles(方块消失特效 )

提供了两个函数接口,多用的面一种,参数参照前面的

[cpp]  view plain copy
  1. /** creates the action with the grid size and the duration */  
  2. static TurnOffTiles* create(float duration, const Size& gridSize);  
  3.   
  4.   
  5. /** creates the action with a random seed, the grid size and the duration */  
  6. static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);  

11、SplitRows、SplitCols

SplitRows :分多行消失特效

SplitCols :分多列消失特效 


[cpp]  view plain copy
  1. /**  
  2.  * rows : 行数  
  3.  */  
  4. SplitRows::create(float duration, unsigned int rows)   
  5.   
  6.   
  7. /**  
  8.  * cols : 列数  
  9.  */    
  10. SplitCols::create(float duration, unsigned int cols)  


12、PageTurn3D

[cpp]  view plain copy
  1. PageTurn3D :3D翻页特效,从右下角往左上角翻  
  2. /**  
  3. * gridSize : 网格大小 
  4. */    
  5. PageTurn3D::create(float duration, const cocos2d::Size &gridSize)  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值