Use of Cocos2d-x3.1 particles, cocos2d-x3.1 Particles

Source: Internet
Author: User

Use of Cocos2d-x3.1 particles, cocos2d-x3.1 Particles

1. header files

#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 File

#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}
Code download: http://download.csdn.net/detail/yuxikuo_1/7861203


How does ios cocos2d flash a flickering particle?

The example system CCParticleSystem to use cocos2d. You can easily generate an example system by searching for such information on the Internet.
 
Cocos2d-iphone Particle anomalies I use a Particle designed to occasionally become abnormal when loading, sometimes very large.

Are you using the participant designer? It is very good.

"Occasionally abnormal", how is it abnormal?
"Sometimes it's very big." What's very big?
If you want to make a program, you still need to be specific and rigorous.
In addition, if it is a probability event, you still need to analyze the program yourself.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.