0

最近两周我在 cocos2d-x 工作。我在 cocos2d-iphone 上做了一个游戏。现在我正在尝试使用 cocos2d-x 从 android 设备上做同样的事情。当玩家收集星星时,我正在使用粒子系统。当玩家第一次收集星星时,粒子系统没有得到显示。之后,对于每个明星收藏,它都会变得可见。我检查了它是否正在执行用于显示粒子系统的功能。

添加粒子系统的代码是:

CCParticleSystemQuad *system = CCParticleSystemQuad::create("stars.plist");
                            system->setTexture(CCTextureCache::sharedTextureCache()->addImage("stern.png"));
                            system->setPosition(starSprite->getPosition().x, starSprite->getPosition().y);
system->setLife(2);
system->setLifeVar(2);
system->setAutoRemoveOnFinish(true);
this->addChild(system,2);

有谁告诉我为什么会这样?

4

1 回答 1

1

使用此代码一次定义您的粒子系统,在 h 文件中声明“系统”,以便稍后在 cpp 文件中使用它。

CCParticleSystemQuad *system = CCParticleSystemQuad::create("stars.plist");
                            system->setTexture(CCTextureCache::sharedTextureCache()->addImage("stern.png"));
                            system->setPosition(starSprite->getPosition().x, starSprite->getPosition().y);
system->setLife(2);
system->setLifeVar(2);
system->stopSystem();
this->addChild(system,2);

现在当你收集星星的时候就放这条线

系统->重置系统();

每次收集星星时,粒子系统都会重置并显示:)

于 2014-09-07T06:05:50.053 回答