com.badlogic.gdx.graphics.g2d.ParticleEffect Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.ParticleEffect. 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: PlayerSmokeTrails.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public SmokeEffect (TrackEffect owner) {
	this.owner = owner;
	effect = new ParticleEffect();
	effect.load(Gdx.files.internal("data/partfx/smoke-small.p"), Art.particles, "");

	baseEmitter = effect.getEmitters().get(0);

	MaxParticleLifeMinMs = baseEmitter.getLife().getHighMin();
	MaxParticleLifeMaxMs = baseEmitter.getLife().getHighMax();
	OriginalParticleScaling = baseEmitter.getScale().getHighMax();
	// MaxParticlesPerEmitterPerSec = baseEmitter.getEmission().getHighMax();

	effect.start();
}
 
Example #4
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();

    };
}
 
Example #5
Source File: Mariano.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void loadAssets(Engine engine) {
    assetsManager = engine.getManager(AssetsManagerGDX.class);
    assetsManager.loadAsset(effect, ParticleEffect.class);
    assetsManager.loadTextureAtlas(atlas);

}
 
Example #6
Source File: UdacityScreen.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void show() {
    batch = new SpriteBatch();
    logo = new Texture("udacity_logo_white.png");
    logoHeight = logo.getHeight() * LOGO_WIDTH / logo.getWidth();

    ParticleEffect touchEffect = new ParticleEffect();
    touchEffect.load(Gdx.files.internal("UdacityEmitter.p"), Gdx.files.internal(""));
    touchEffect.setEmittersCleanUpBlendFunction(false);
    touchEffectPool = new ParticleEffectPool(touchEffect, 1, 2);
    Gdx.input.setInputProcessor(this);
}
 
Example #7
Source File: Particle.java    From Bomberman_libGdx with MIT License 5 votes vote down vote up
public Particle(String particleFileString, float x, float y) {
    particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal(particleFileString), Gdx.files.internal("particles"));
    particleEffect.setPosition(x, y);
    particleEffect.scaleEffect(1 / GameManager.PPM);
    particleEffect.start();
}
 
Example #8
Source File: UdacityScreen.java    From ud406 with MIT License 5 votes vote down vote up
@Override
public void show() {
    batch = new SpriteBatch();
    // TODO: Scavenger hunt! Where does this logo live?
    logo = new Texture("udacity_logo_white.png");
    logoHeight = logo.getHeight() * LOGO_WIDTH / logo.getWidth();

    ParticleEffect touchEffect = new ParticleEffect();
    // TODO: Same question. Where does UdacityEmitter.p live? How are we loading it?
    touchEffect.load(Gdx.files.internal("UdacityEmitter.p"), Gdx.files.internal(""));
    touchEffect.setEmittersCleanUpBlendFunction(false);
    touchEffectPool = new ParticleEffectPool(touchEffect, 1, 2);
    Gdx.input.setInputProcessor(this);
}
 
Example #9
Source File: LegacyCompareTest.java    From talos with Apache License 2.0 4 votes vote down vote up
public LegacyActor (FileHandle effect, TextureAtlas atlas) {
	particleEffect = new ParticleEffect();
	particleEffect.loadEmitters(effect);
	particleEffect.loadEmitterImages(atlas);
	particleEffect.start();
}
 
Example #10
Source File: ParticleEffectActor.java    From Norii with Apache License 2.0 4 votes vote down vote up
public ParticleEffectActor(ParticleEffect particleEffect) {
    super();
    this.particleEffect = particleEffect;
}
 
Example #11
Source File: Utility.java    From Norii with Apache License 2.0 4 votes vote down vote up
public static void loadParticleAsset(final String particleFilenamePath) {
	loadAsset(particleFilenamePath, ParticleEffect.class, new ParticleEffectLoader(filePathResolver));
}
 
Example #12
Source File: Utility.java    From Norii with Apache License 2.0 4 votes vote down vote up
public static ParticleEffect getParticleAsset(final String particleFilenamePath) {
	return (ParticleEffect) getAsset(particleFilenamePath, ParticleEffect.class);
}
 
Example #13
Source File: Mariano.java    From Entitas-Java with MIT License 4 votes vote down vote up
@Override
public GameEntity create(Engine engine, Entitas entitas) {
    PhysicsManagerGDX physics = engine.getManager(PhysicsManagerGDX.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();

    TextureAtlas textureAtlas = assetsManager.getTextureAtlas(atlas);
    ParticleEffect dustEffect = assetsManager.get(effect, ParticleEffect.class);

    Array<TextureAtlas.AtlasRegion> heroWalking = textureAtlas.findRegions("Andando");
    Array<TextureAtlas.AtlasRegion> heroJump = textureAtlas.findRegions("Saltando");
    Array<TextureAtlas.AtlasRegion> heroFall = textureAtlas.findRegions("Cayendo");
    Array<TextureAtlas.AtlasRegion> heroIdle = textureAtlas.findRegions("Parado");

    Map<String, Animation<TextureRegion>> animationStates = EntitasCollections.createMap(String.class, Animation.class);
    animationStates.put("walking", new Animation(0.02f, heroWalking, Animation.PlayMode.LOOP));
    animationStates.put("jump", new Animation(0.02f * 7, heroJump, Animation.PlayMode.NORMAL));
    animationStates.put("fall", new Animation(0.02f * 5, heroFall, Animation.PlayMode.NORMAL));
    animationStates.put("idle", new Animation(0.02f * 4, heroIdle, Animation.PlayMode.LOOP));

    Body bodyPlayer = bodyBuilder.fixture(bodyBuilder.fixtureDefBuilder()
            .boxShape(0.35f, 1)
            .density(1))
            .type(BodyDef.BodyType.DynamicBody)
            .fixedRotation()
            .position(0, 5)
            .mass(1)
            .build();

    GameEntity entity = entitas.game.createEntity();
    entity.addRigidBody(bodyPlayer)
            .addAnimations(animationStates, animationStates.get("idle"), 0)
            .addTags("Mariano")
            .setInteractive(true)
            .addTextureView(null, new Bounds(0.9f, 1.15f), false, false, 1, 1, Color.WHITE)
            .addInputController((inputManager, context) -> {
                boolean isGround = false;
                SensorEntity sensor = Indexed.getSensorsEntity(entity, "CollisionGround");
                if (sensor.getCollisionSensor().collisionSignal)
                    isGround = true;


                Vector2 impulse = new Vector2();
                if (inputManager.isKeyDown(Input.Keys.D)) {
                    impulse.x = 2;
                    if (isGround)
                        entity.getAnimations().currentAnimation = entity.getAnimations().animationStates.get("walking");
                    entity.getTextureView().flipX = false;
                } else if (inputManager.isKeyDown(Input.Keys.A)) {
                    impulse.x = -2;
                    if (isGround)
                        entity.getAnimations().currentAnimation = entity.getAnimations().animationStates.get("walking");
                    entity.getTextureView().flipX = true;
                }

                if (inputManager.isKeyDown(Input.Keys.W)) {
                    if (isGround) impulse.y = 4;
                    entity.getAnimations().currentAnimation = entity.getAnimations().animationStates.get("jump");
                }

                Vector2 vel = bodyPlayer.getLinearVelocity();
                if (!inputManager.isKeyDown(Input.Keys.A) && !inputManager.isKeyDown(Input.Keys.D) && isGround) {
                    bodyPlayer.setLinearVelocity(new Vector2(0, vel.y));
                    entity.getAnimations().currentAnimation = entity.getAnimations().animationStates.get("idle");
                }

                if (Math.abs(vel.x) > 7) {
                    vel.x = Math.signum(vel.x) * 7;
                    bodyPlayer.setLinearVelocity(new Vector2(vel.x, vel.y));
                }
                if (!isGround && vel.y < 0) {
                    entity.getAnimations().currentAnimation = entity.getAnimations().animationStates.get("fall");
                }
                bodyPlayer.applyLinearImpulse(impulse, bodyPlayer.getWorldCenter(), false);

            });

    entitas.sensor.createEntity()
            .addCollisionSensor("Ground")
            .addLink(entity.getCreationIndex(), "CollisionGround");

    entitas.actuator.createEntity()
            .addCameraActuator(((EngineGDX) engine).getCamera(), (short) 0.3f, 0.08f, 6, 1, "Mariano")
            .addLink(entity.getCreationIndex(), "CameraActuator", true);

    entitas.actuator.createEntity()
            .addParticleEffectActuator(dustEffect,true,-1,-1)
            .addLink(entity.getCreationIndex(), "EffectActuator", true);


    return entity;

}
 
Example #14
Source File: Mariano.java    From Entitas-Java with MIT License 4 votes vote down vote up
@Override
public void loadAssets(Engine engine) {
    assetsManager = engine.getManager(BaseAssetsManager.class);
    assetsManager.loadAsset(effect, ParticleEffect.class);
    assetsManager.loadTextureAtlas(atlas);
}