2.CCGridAction(3D效果),3D反转特效,凸透镜特效,液体特效,3D翻页特效,水波纹特效,3D晃动的特效,扭曲旋转特效,波动特效,3D波动特效

涂作权 2014-10-29

Create



1 类图组织

2 实例

CCSprite * spr = CCSprite::create("HelloWorld.png");

spr->setPosition(ccp(winSize.width/2,winSize.height/2));

addChild(spr);

 

//GridAction

//CCFlipX3D * action = CCFlipX3D::create(2);

//CCFlipY3D * action = CCFlipY3D::create(2);

//CCLens3D * action = CCLens3D::create(2,

CCSize(20,20),ccp(240,160),100);

//CCLiquid * action = CCLiquid::create(4, CCSize(20, 20), 20, 35);

//CCPageTurn3D * action = CCPageTurn3D::create(2, CCSize(20,20));

//CCRipple3D * action = CCRipple3D::create(2,

CCSize(20,20),ccp(240,160),40,20,30);

//CCShaky3D * action = CCShaky3D::create(2,

CCSize(20,20),20,false);

//CCTwirl * action = CCTwirl::create(2,

CCSize(20,20),ccp(240,160),3,30);

//CCWaves * action = CCWaves::create(2,

CCSize(20,20),30,30,false,true);

//CCWaves3D * action = CCWaves3D::create(2, CCSize(20,20),30,30);

 

3  Y  3D反转特效(CCFlipX3D

CCActionInterval* filpX = CCFlipX3D::create(5); 

sp->runAction(filpX); 

//作用:Y3D反转特效

//参数:特效持续的时间

案例:

T18Grid3D.h

#ifndef __T18Grid3D_H__

#define __T18Grid3D_H__

 

#include "cocos2d.h"

#include "TBack.h"

USING_NS_CC;

class T18Grid3D :public TBack

{

public:

    static CCScene * scene();

    CREATE_FUNC(T18Grid3D);

    bool init();

};

 

#endif

T18Grid3D.cpp

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //x  3D反转特效

    CCActionInterval* filpX = CCFlipX3D::create(5);

    spr->runAction(filpX);

 

    return true;

}

运行效果:

Y3D发转特效

CCActionInterval* filpY = CCFlipY3D::create(5);

spr->runAction(filpY);

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //x  3D反转特效

    CCActionInterval * filpY = CCFlipY3D::create(5);

    spr->runAction(filpY);

 

    return true;

}

运行效果:

凸透镜特效

CCLen3D * CCLen3D::create(float duration,const CCSize & gridSize,const CCPoint& position,float radius);

 

CCPointMake表示的是创建一个点)

CCActionInterval* lens = CCLens3D::create(2, CCSize(10, 10),CCPointMake(240, 160), 240);

spr->runAction(lens);

作用:凸镜特效

参数:网格持续的时间

参数:网格大小

参数:凸透镜中心点

参数:凸镜半径

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //凸透镜特效

    CCLens3D * action = CCLens3D::create(20,CCSize(20,20),

        ccp(240,160),100);

    spr->runAction(action);

 

    return true;

}

运行结果:

CCLiquid* CCLiquid::create(float duration, const CCSize& gridSize, unsigned int waves, float amplitude);

spr->runAction(liquid);

作用:液体特效

参数:特效持续时间

参数:网格大小

参数:wave个数

参数:振幅

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //液体震荡特效

    CCLiquid *action = CCLiquid::create(8,CCSize(4,4),10,3);

    spr->runAction(action);

 

    return true;

}

运行结果(出现液体的震荡效果):

3D 翻页特效

CCPageTurn3D* CCPageTurn3D::create(float duration, const CCSize& gridSize);

CCActionInterval * pageTurn3D = CCPageTurn3D::create(4,CCSize(20,20));

spr->runAction(pageTurn3D);

//作用:3D翻页特效

//参数:特效持续的时间

//参数:网格大小

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //3D 翻页特效

    CCPageTurn3D * action = CCPageTurn3D::create(20, CCSize(20, 20));

    spr->runAction(action);

 

    return true;

}

水波纹特效

CCRipple3D* CCRipple3D::create(

float duration,

const CCSize& gridSize,

const CCPoint& position,

float radius,

unsigned int waves,

float amplitude);

作用:水波特效

参数:特效持续的时间

参数:网格大小

参数:起始位置

参数:半径

参数:速率

参数:振幅

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //水波纹特效

    CCActionInterval * action = CCRipple3D::create(

        10,                     //特效持续的时间

        CCSize(10, 10),         //网格大小

        CCPointMake(240, 210),  //起始位置

        40,                     //半径

        6,                      //速率

        160);                   //振幅

    spr->runAction(action);

 

    return true;

}

3D 晃动特效

CCShaky3D *CCShaky3D::create(float duration,const CCSize& gridSize,int range,bool shakeZ);

CCActionInterval* shaky3D = CCShaky3D::create(5, CCSize(10, 10), 15, false);

sp->runAction(shaky3D);

作用:创建一个3d晃动的特效

参数:特效持续的时间

参数:网格大小

参数:晃动的范围

参数:是否有Z轴晃动

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    CCShaky3D * action = CCShaky3D::create(

        20,                //特效持续的时间

        CCSize(70, 70),    //网格大小

        60,                //晃动的范围

        true);             //是否有z轴晃动

 

    spr->runAction(action);

 

    return true;

}

扭曲旋转特效

CCTwirl* CCTwirl::create(float duration, const CCSize& gridSize, CCPoint position, unsigned int twirls, float amplitude);

CCActionInterval* twirl = CCTwirl::create(50, CCSize(10, 10), CCPointMake(240, 160), 2, 2.5);

sp->runAction(twirl);

//作用:扭曲旋转特效

//参数:特效持续时间

//参数:网格大小

//参数:扭曲旋转中心点

//参数:扭曲旋转的次数

//参数:振幅

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    CCActionInterval* action = CCTwirl::create(

        50,                     //特效持续时间  

        CCSize(10, 10),         //网格大小

        CCPointMake(240, 160), //扭曲旋转中心点

        2,                      //扭曲旋转的次数

        2.5);                   //振幅

 

    spr->runAction(action);

 

    return true;

}

波动特效

CCWaves* CCWaves::create(

float duration,

const CCSize& gridSize,

unsigned int waves,

float amplitude,

bool horizontal,

bool vertical);

作用:创建一个波动特效

参数:特效持续时间

参数:网格大小

参数:波动的速率

参数:振幅

参数:水平波动

参数:垂直波动

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    //创建一个波动特效

    CCWaves * action = CCWaves::create(

        20,                //特效持续时间

        CCSize(20, 20),    //网格大小

        30,                //波动的速率

        30,                //振幅

        false,             //水平波动

        true);             //垂直波动

 

    spr->runAction(action);

 

    return true;

}

运行结果:

3D波动特效(创建一个3D波动特效)

CCWaves3D* CCWaves3D::create(

float duration,

const CCSize& gridSize,

unsigned int waves,

float amplitude);

参数:特效持续时间

参数:网格大小

参数:波动的速率

参数:振幅

#include "T18Grid3D.h"

#include "AppMacros.h"

 

CCScene *T18Grid3D::scene()

{

    CCScene * scene = CCScene::create();

    T18Grid3D * layer = T18Grid3D::create();

    scene->addChild(layer);

    return scene;

}

 

bool T18Grid3D::init()

{

    TBack::init();

   

    //Grid3D

    CCSprite * spr = CCSprite::create("HelloWorld.png");

    spr->setPosition(ccp(winSize.width / 2, winSize.height / 2));

    addChild(spr);

 

    CCWaves3D * action = CCWaves3D::create(

        20,

        CCSize(20,20),

        30,

        30);

 

    spr->runAction(action);

 

    return true;

}

运行结果:

 

登录 后评论
下一篇
云栖号资讯小编
2144人浏览
2020-06-01
相关推荐
0
0
0
1110