本文整理汇总了C++中ParticleEmitter::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::isEnabled方法的具体用法?C++ ParticleEmitter::isEnabled怎么用?C++ ParticleEmitter::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::isEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void ParticleSystem::update(float delta) {
if (sprite == NULL) {
std::cout << "sprite was null" << std::endl;
return;
return;
}
removeMe.clear();
//std::cout << "1" << std::endl;
for(unsigned int i = 0; i < emitters.size(); i++) {
ParticleEmitter* emitter = emitters.at(i);
if (emitter->isEnabled()) {
//std::cout << "en" << std::endl;
emitter->update(this, delta);
//std::cout << "en2" << std::endl;
if (removeCompletedEmitters) {
if (emitter->isComplete()) {
removeMe.push_back(emitter);
particlesByEmitter.erase(emitter);
}
}
}
}
//std::cout << "2" << std::endl;
// remove items in removeMe from emitters.
vector<ParticleEmitter*>::iterator ito = emitters.begin();
while (ito != emitters.end()) {
ParticleEmitter* e = (*ito);
vector<ParticleEmitter*>::iterator ito2 = removeMe.begin();
while (ito2 != removeMe.end()) {
ParticleEmitter* e2 = (*ito2);
if (e == e2) {
ito = emitters.erase(ito);
continue;
}
ito2++;
}
ito++;
}
//std::cout << "3" << std::endl;
pCount = 0;
if (!particlesByEmitter.empty()) {
//std::cout << "4: " << particlesByEmitter.size() << std::endl;
map<ParticleEmitter*, ParticlePool*>::iterator it = particlesByEmitter.begin();
while (it != particlesByEmitter.end()) {
ParticleEmitter* emitter = it->first;
if (emitter->isEnabled()) {
ParticlePool* pool = it->second;
//std::cout << "5" << std::endl;
for (unsigned int i = 0; i < pool->particlesActive.size(); i++) {
if (pool->particlesActive.at(i)->getLife() > 0) {
pool->particlesActive.at(i)->update(delta);
pCount++;
}
}
}
it++;
//std::cout << "6" << std::endl;
}
}
}
示例2: render
void ParticleSystem::render(float x, float y) {
if (sprite == NULL) {
std::cout << "sprite was null" << std::endl;
return;
}
if (!m_visible) {
std::cout << "invisible" << std::endl;
return;
}
Renderer* g = ARK2D::getRenderer();
g->pushMatrix();
g->translate(x, y);
if (blendingMode == BLEND_ADDITIVE) { // TODO: g->setBlendMode(Renderer::BLEND_ADDITIVE);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
g->setBlendMode(Renderer::BLEND_ADDITIVE);
}
//if (isUsePoints()) {
// glEnable(GL_POINT_SMOOTH);
//}
for(unsigned int i = 0; i < emitters.size(); i++) {
ParticleEmitter* emitter = emitters.at(i);
if (!emitter->isEnabled()) {
continue;
}
//std::cout << "render" << std::endl;
// check for additive override and enable when set
if (emitter->useAdditive()) {
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
g->setBlendMode(Renderer::BLEND_ADDITIVE);
}
// now get the particle pool for this emitter and render all particles that are in use
ParticlePool* pool = particlesByEmitter.find(emitter)->second;
Image* image = emitter->getImage();
if (image == NULL && !emitter->usePoints()) {// && (!usePoints)) {
//image = sprite;
//emitter->u
RendererState::start(RendererState::TEXTURE, sprite->getTexture()->getId());
//sprite->bind(); // we need to cancel this out if we're rendering points.
}
//if (!emitter->isOriented() && !emitter->usePoints(this)) {
// image->startUse();
//}
/*!
* todo: we don't know what particles are points and what are images
* so are currently binding and unbinding the default image LOTS.
* TOO MUCH.
*/
for (unsigned int i = 0; i < pool->particlesActive.size(); i++) {
if (pool->particlesActive.at(i)->inUse()) {
pool->particlesActive.at(i)->render();
}
}
//if (!emitter->isOriented() && !emitter->usePoints(this)) {
// image->endUse();
//}
// reset additive blend mode
if (emitter->useAdditive()) {
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g->setBlendMode(Renderer::BLEND_NORMAL);
}
//std::cout << "render2" << std::endl;
}
//if (isUsePoints()) {
// glDisable(GL_POINT_SMOOTH);
//}
if (blendingMode == BLEND_ADDITIVE) {
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g->setBlendMode(Renderer::BLEND_NORMAL);
}
g->setDrawColor(Color::white);
//g->translate(x * -1, y * -1);
g->popMatrix();
}