【问题标题】:Can Someone Give Me A Simple COcos2d-X Particle Example?谁能给我一个简单的 COcos2d-X 粒子示例?
【发布时间】:2012-10-11 22:47:08
【问题描述】:

我只是想用Cocos2d-x和C++做一个CCParticleExplsion,但是找遍了好像找不到。 ObjC 示例:

CCParticleSystem *firework = [[CCParticleExplosion alloc] initWithTotalParticles:200];
[self addChild:firework];
[firework setTexture:[[CCTextureCache sharedTextureCache] addImage:@"star.png"]];

【问题讨论】:

    标签: cocos2d-x particles ccparticlesystem


    【解决方案1】:

    在大多数情况下,ParticleTexture 都带有 plist 文件,而整个 plist 文件来自粒子设计器。通常,我们使用

    CCParticleSystemQuad* p = CCParticleSystemQuad::create("whatever_particle.plist");
    this->addChild(p);
    

    但是如果你想使用cocos2d-x自带的粒子,你可以在cocos2d-x框架自带的Test Cases中查看如何使用。文件名为 ParticleTest.cpp

    【讨论】:

      【解决方案2】:

      CCParticleExplosioncocos2dx/particle_nodes/CCParticleExamples.h 中声明。

      这是您的 Objective C 代码的 C++ 等效代码:

      CCTexture2D* texture = CCTextureCache::sharedTextureCache()->textureForKey("star.png");
      CCParticleExplosion* firework = CCParticleExplosion::create();
      firework->setTexture(texture);
      

      【讨论】:

        【解决方案3】:

        查看 cocos2d-x 根文件夹中的测试文件夹。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-07-21
          • 2013-06-06
          • 1970-01-01
          • 1970-01-01
          • 2020-09-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多