zoukankan      html  css  js  c++  java
  • cocos2d-x游戏开发之烟花粒子效果

    //散烟花及“太”“棒”“了”效果

    void mygame::playfire() {

          sprite *tai = sprite::create("tai.png");  

          tai->setposition(director::getinstance()->getvisiblesize().width *0.4, 540);  

          this->addchild(tai, 4);  

          actioninterval *forwardouttai = fadeout::create(2.0f);  tai->runaction(forwardouttai);

      

          sprite *bang = sprite::create("bang.png");  

          bang->setposition(director::getinstance()->getvisiblesize().width *0.6, 540);

          this->addchild(bang, 4);  

          actioninterval *forwardoutbang = fadeout::create(2.0f);  

          bang->runaction(forwardoutbang);

          sprite *le = sprite::create("le.png");  

          le->setposition(director::getinstance()->getvisiblesize().width *0.8, 540);  

          this->addchild(le, 4);  

          actioninterval *forwardoutle = fadeout::create(2.0f);  

          le->runaction(forwardoutle);

          for (i = 1; i <= 3; i++)  {  

          log("%s", "------------playfire");   

          auto explosion = particleexplosion::create();   

          explosion->settexture(director::getinstance()->gettexturecache()->addimage("fire.png"));  

          explosion->setposition(vec2(50 + i * 280, 440));   

          explosion->settotalparticles(300);   

          explosion->setlife(8.0f);   

          this->addchild(explosion, 5);

          // 播放烟花声音  

          simpleaudioengine::getinstance()->preloadeffect("lose.mp3");   

          simpleaudioengine::getinstance()->playeffect("lose.mp3");   

          simpleaudioengine::getinstance()->setbackgroundmusicvolume(0.5);

     }

    }

  • 相关阅读:
    JSTL 标签库
    C++(一)— stringstream的用法
    深度学习—反向传播的理解
    深度学习—线性分类器理解
    Python—numpy.bincount()
    Python—numpy.argsort()
    Python—numpy.flatnonzero()
    C++(零)— 提高程序运行效率
    机器学习(八)—GBDT 与 XGBOOST
    机器学习(七)—Adaboost 和 梯度提升树GBDT
  • 原文地址:https://www.cnblogs.com/lchzls/p/5059216.html
Copyright © 2011-2022 走看看