特效

新建工程,名为testEffect

修改HelloWorldScene.h

#ifndef __HELLOWORLD_SCENE_H__

#define __HELLOWORLD_SCENE_H__


#include "cocos2d.h"


class HelloWorld : public cocos2d::CCLayer

{

public:

    // Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer)

    virtual bool init();


    // there's no 'id' in cpp, so we recommend to return the class instance pointer

    static cocos2d::CCScene* scene();    

    // preprocessor macro for "static create()" constructor ( node() deprecated )

    CREATE_FUNC(HelloWorld);

};


#endif // __HELLOWORLD_SCENE_H__

修改HelloWorldScene.cpp

#include "HelloWorldScene.h"

#include "SimpleAudioEngine.h"


using namespace cocos2d;

using namespace CocosDenshion;

#define EffectMacro 22

CCScene* HelloWorld::scene()

{

    // 'scene' is an autorelease object

    CCScene *scene = CCScene::create();

    

    // 'layer' is an autorelease object

    HelloWorld *layer = HelloWorld::create();


    // add layer as a child to scene

    scene->addChild(layer);


    // return the scene

    return scene;

}


// on "init" you need to initialize your instance

bool HelloWorld::init()

{

    //

    // 1. super init first

    if ( !CCLayer::init() )

    {

        return false;

    }

    

    CCSize size=CCDirector::sharedDirector()->getWinSize();

    CCSprite *sp=CCSprite::create("Default.png");

    sp->setPosition(ccp(size.width*0.5, size.height*0.5));

    sp->setRotation(90);

    addChild(sp);

    

    switch (EffectMacro) {

        case 1:

        {

            //----------CCShaky3D

            CCActionInterval *shaky3D=CCShaky3D::create(15, false, ccg(15, 10), 4);

            sp->runAction(shaky3D);

        }

            break;

        case 2:

        {

            //--------CCShakyTiles3D

            CCActionInterval *shakyTiles3D=CCShakyTiles3D::create(15, true, ccg(15, 10), 4);

            sp->runAction(shakyTiles3D);

        }

            break;

        case 3:

        {

            //--------CCWaves

            CCActionInterval *waves=CCWaves::create(10, 20, true,true,ccg(16, 12),4);

            sp->runAction(waves);

        }

            break;

        case 4:

        {

            //--------CCWaves3D

            CCActionInterval *waves3D=CCWaves3D::create(10, 20, ccg(16, 12),3);

            sp->runAction(waves3D);

        }

            break;

        case 5:

        {

            //------CCWavesTiles3D

            CCActionInterval *wavesTiles3D=CCWavesTiles3D::create(10, 20, ccg(16, 12),3);

            sp->runAction(wavesTiles3D);

        }

            break;

        case 6:

        {

            //------CCFlipX3D

            CCActionInterval *flipX3D=CCFlipX3D::create(3);

            sp->runAction(flipX3D);

        }

            break;

        case 7:

        {

            //------CCFlipY3D

            CCActionInterval *flipY3D=CCFlipY3D::create(3);

            sp->runAction(flipY3D);

        }

            break;

        case 8:

        {

            //--------CCLens3D

            CCActionInterval *lens3D=CCLens3D::create(CCPointMake(size.width/2, size.height/2), 240, ccg(15, 10), 2);

            sp->runAction(lens3D);

        }

            break;

        case 9:

        {

            //---------CCRipple3D

            CCActionInterval *ripple3D=CCRipple3D::create(CCPointMake(size.width/2, size.height/2), 240, 4,160,ccg(32,24), 3);

            sp->runAction(ripple3D);

        }

            break;

        case 10:

        {

            //--------CCLiquid

            CCActionInterval *liquid=CCLiquid::create(4, 20, ccg(16, 12), 4);

            sp->runAction(liquid);

        }

            break;

        case 11:

        {

            //--------CCTwirl

            CCActionInterval *twirl=CCTwirl::create(CCPointMake(size.width/2, size.height/2),2,2.5f,ccg(12, 8),3);

            sp->runAction(twirl);

        }

            break;

        case 12:

        {

            //-------CCShuffleTiles

            CCActionInterval *shuffleTiles=CCShuffleTiles::create(16,ccg(16, 12),2);

            sp->runAction(shuffleTiles);

        }

            break;

        case 13:

        {

            //-------CCShatteredTiles3D

            CCActionInterval *shuffleTiles3D=CCShatteredTiles3D::create(25,true,ccg(16, 12),3);

            sp->runAction(shuffleTiles3D);

        }

            break;

        case 14:

        {

            //-------CCFadeOutTRTiles

            CCActionInterval *fadeOutTRTiles=CCFadeOutTRTiles::create(ccg(16, 12),2);

            sp->runAction(fadeOutTRTiles);

        }

            break;

        case 15:

        {

            //-------CCFadeOutBLTiles

            CCActionInterval *fadeOutBLTiles=CCFadeOutBLTiles::create(ccg(16, 12),2);

            sp->runAction(fadeOutBLTiles);

        }

            break;

        case 16:

        {

            //-------CCFadeOutUpTiles

            CCActionInterval *fadeOutUpTiles=CCFadeOutUpTiles::create(ccg(16, 12),2);

            sp->runAction(fadeOutUpTiles);

        }

            break;

        case 17:

        {

            //-------CCFadeOutDownTiles

            CCActionInterval *fadeOutDownTiles=CCFadeOutDownTiles::create(ccg(16, 12),2);

            sp->runAction(fadeOutDownTiles);

        }

            break;

        case 18:

        {

            //-----CCTurnOffTiles

            CCActionInterval *turnOffTiles=CCTurnOffTiles::create(ccg(48, 32),2);

            sp->runAction(turnOffTiles);

        }

            break;

        case 19:

        {

            //-----CCJumpTiles3D

            CCActionInterval *jumpTiles3D=CCJumpTiles3D::create(1,30,ccg(15, 10),2);

            sp->runAction(jumpTiles3D);

        }

            break;

        case 20:

        {

            //------CCSplitRows

            CCActionInterval *splitRows=CCSplitRows::create(10,2);

            sp->runAction(splitRows);

        }

            break;

        case 21:

        {

            //------CCSplitCols

            CCActionInterval *splitCols=CCSplitCols::create(13,3);

            sp->runAction(splitCols);

        }

            break;

        case 22:

        {

            //------CCPageTurn3D

            CCActionInterval *pageTurn3D=CCPageTurn3D::create(ccg(15, 10), 3);

            sp->runAction(pageTurn3D);

        }

            break;

        default:

            break;

    }

    return true;

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值