Cocos2d-x3.1粒子使用

來源:互聯網
上載者:User

標籤:cocos2d-x3.1   粒子   

1、標頭檔

#include "cocos2d.h"USING_NS_CC;class WaterWaveDemo : public Layer{public:    static cocos2d::Scene* createScene();        // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone    virtual bool init();        // a selector callback    void menuCloseCallback(cocos2d::Ref* pSender);        // implement the "static create()" method manually    CREATE_FUNC(WaterWaveDemo);};

2、cpp檔案

#include "WaterWaveDemo.h"#include "SimpleAudioEngine.h"using namespace CocosDenshion;Scene* WaterWaveDemo::createScene(){    // 'scene' is an autorelease object    auto scene = Scene::create();        // 'layer' is an autorelease object    auto layer = WaterWaveDemo::create();        // add layer as a child to scene    scene->addChild(layer);        // return the scene    return scene;    }bool WaterWaveDemo::init(){    bool bRet = false;    do{        CC_BREAK_IF(!Layer::init());                auto listener = EventListenerTouchOneByOne::create();        listener->setSwallowTouches(true);                listener->onTouchBegan = [&](Touch* touch,Event* event){                      auto touchPosition = touch->getLocation();            ParticleSystemQuad* mParticle = ParticleSystemQuad::create("showClick.plist");            mParticle->setScale(0.5);            mParticle->setPosition(touchPosition);            mParticle->setAutoRemoveOnFinish(true);            addChild(mParticle);                        return false;        };                Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);        bRet = true;    }while(0);    return bRet;}void WaterWaveDemo::menuCloseCallback(Ref* pSender){#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");    return;#endif        Director::getInstance()->end();    #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)    exit(0);#endif}
代碼下載:http://download.csdn.net/detail/yuxikuo_1/7861203

Cocos2d-x3.1粒子使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.