Game Development Reference
In-Depth Information
Time for action - creating particle systems
For particles, all we need is the XML file describing the particle system's properties.
1. So let's go to GameLayer.cpp .
2. The game initializes by calling createGameScreen , which is already in place,
then createParticles and createStarGrid , which is also implemented.
So let's go over the createParticles method now.
3. Go to that method in GameLayer.cpp and add the following code:
_jet = ParticleSystemQuad::create("jet.plist");
_jet->setSourcePosition(Vec2(-_rocket->getRadius() *
0.8f,0));
_jet->setAngle(180);
_jet->stopSystem();
this->addChild(_jet, kBackground);
_boom = ParticleSystemQuad::create("boom.plist");
_boom->stopSystem();
this->addChild(_boom, kForeground);
_comet = ParticleSystemQuad::create("comet.plist");
_comet->stopSystem();
_comet->setPosition(Vec2(0, _screenSize.height *
0.6f));
_comet->setVisible(false);
this->addChild(_comet, kForeground);
_pickup = ParticleSystemQuad::create("plink.plist");
_pickup->stopSystem();
this->addChild(_pickup, kMiddleground);
_warp = ParticleSystemQuad::create("warp.plist");
_warp->setPosition(_rocket->getPosition());
this->addChild(_warp, kBackground);
_star = ParticleSystemQuad::create("star.plist");
_star->stopSystem();
Search WWH ::




Custom Search