Java Code Examples for com.badlogic.gdx.graphics.g2d.ParticleEffect#update()

The following examples show how to use com.badlogic.gdx.graphics.g2d.ParticleEffect#update() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActuatorEntity.java    From Entitas-Java with MIT License 6 votes vote down vote up
public ActuatorEntity addParticleEffectActuator(ParticleEffect effect,
		boolean autoStart, float locaPosX, float locaPosY) {
	ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
	if (component == null) {
		component = new ParticleEffectActuator(effect, autoStart, locaPosX,
				locaPosY);
	} else {
		component.particleEffect = effect;
		component.actuator = (indexOwner) -> {
			GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
			RigidBody rc = owner.getRigidBody();
			Transform transform = rc.body.getTransform();
			effect.setPosition(transform.getPosition().x + locaPosX,
					transform.getPosition().y + locaPosY);
			effect.update(Gdx.graphics.getDeltaTime());
			if (autoStart && effect.isComplete())
				effect.start();
		};
	}
	addComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
	return this;
}
 
Example 2
Source File: ActuatorEntity.java    From Entitas-Java with MIT License 6 votes vote down vote up
public ActuatorEntity replaceParticleEffectActuator(ParticleEffect effect,
		boolean autoStart, float locaPosX, float locaPosY) {
	ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
	if (component == null) {
		component = new ParticleEffectActuator(effect, autoStart, locaPosX,
				locaPosY);
	} else {
		component.particleEffect = effect;
		component.actuator = (indexOwner) -> {
			GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
			RigidBody rc = owner.getRigidBody();
			Transform transform = rc.body.getTransform();
			effect.setPosition(transform.getPosition().x + locaPosX,
					transform.getPosition().y + locaPosY);
			effect.update(Gdx.graphics.getDeltaTime());
			if (autoStart && effect.isComplete())
				effect.start();
		};
	}
	replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator,
			component);
	return this;
}
 
Example 3
Source File: ParticleEffectActuator.java    From Entitas-Java with MIT License 5 votes vote down vote up
public ParticleEffectActuator(ParticleEffect effect, boolean autoStart, float locaPosX, float locaPosY) {
    this.particleEffect = effect;
    this.actuator = (indexOwner)-> {
        GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
        RigidBody rc = owner.getRigidBody();
        Transform transform = rc.body.getTransform();
        effect.setPosition(transform.getPosition().x + locaPosX, transform.getPosition().y + locaPosY);
        effect.update(Gdx.graphics.getDeltaTime());
        if(autoStart && effect.isComplete()) effect.start();

    };
}