Beispiel #1
0
void ParticleComponent::emitParticle()
{
	Particle particle(mParticleLifetime());
	particle.position = mParticlePosition() + getWorldPosition();
	particle.velocity = mParticleVelocity();
	particle.rotation = mParticleRotation();
	particle.rotationSpeed = mParticleRotationSpeed();
	particle.scale = mParticleScale();
	particle.color = mParticleColor();
	particle.textureIndex = mParticleTextureIndex();
	mParticles.push_back(particle);
}
Beispiel #2
0
void UniversalEmitter::operator() (EmissionInterface& system, sf::Time dt)
{
	const std::size_t nbParticles = computeParticleCount(dt);

	for (std::size_t i = 0; i < nbParticles; ++i)
	{
		// Create particle and specify parameters
		Particle particle( mParticleLifetime() );
		particle.position = mParticlePosition();
		particle.velocity = mParticleVelocity();
		particle.rotation = mParticleRotation();
		particle.rotationSpeed = mParticleRotationSpeed();
		particle.scale = mParticleScale();
		particle.color = mParticleColor();
		particle.textureIndex = mParticleTextureIndex();

		system.emitParticle(particle);
	}
}
void UniversalEmitterNode::emitParticles(sf::Time dt)
{	
	mAccumulatedTime += dt;
	
	while(mAccumulatedTime > mEmissionInterval)
	{
	    mAccumulatedTime -= mEmissionInterval;
		
	    Particle particle;
		particle.position = getWorldPosition() + mParticlePosition();
		particle.velocity = mParticleVelocity();
		particle.rotation = mParticleRotation();
		particle.rotationSpeed = mParticleRotationSpeed();
		particle.scale = mParticleScale();
		particle.color = mParticleColor();
		particle.textureIndex = mParticleTextureIndex();
	    particle.lifetime = sf::Time::Zero;
	    particle.totalLife = mParticleLifetime();
		
		mParticleSystem->addParticle(particle);
	}
}