Search in sources :

Example 1 with TextureView

use of ilargia.egdx.logicbricks.component.game.TextureView in project Entitas-Java by Rubentxu.

the class AnimationSystem method execute.

@Override
public void execute(float deltaTime) {
    for (GameEntity e : _groupAnimation.getEntities()) {
        Animations animations = e.getAnimations();
        TextureView view = e.getTextureView();
        animations.time += deltaTime;
        Animation<TextureRegion> animation = animations.currentAnimation;
        if (animation != null) {
            view.texture = animation.getKeyFrame(animations.time);
        }
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Animations(ilargia.egdx.logicbricks.component.game.Animations) TextureView(ilargia.egdx.logicbricks.component.game.TextureView)

Example 2 with TextureView

use of ilargia.egdx.logicbricks.component.game.TextureView in project Entitas-Java by Rubentxu.

the class ActuatorEntity method addTextureActuator.

public ActuatorEntity addTextureActuator(Bounds bounds, int opacity, Boolean flipX, Boolean flipY, Color tint) {
    TextureActuator component = (TextureActuator) recoverComponent(ActuatorComponentsLookup.TextureActuator);
    if (component == null) {
        component = new TextureActuator(bounds, opacity, flipX, flipY, tint);
    } else {
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            TextureView view = owner.getTextureView();
            if (bounds != null)
                view.bounds = bounds;
            if (flipX != null)
                view.flipX = flipX;
            if (flipY != null)
                view.flipY = flipY;
            if (opacity != -1)
                view.opacity = opacity;
            if (tint != null)
                view.tint = tint;
        };
    }
    addComponent(ActuatorComponentsLookup.TextureActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) TextureActuator(ilargia.egdx.logicbricks.component.actuator.TextureActuator)

Example 3 with TextureView

use of ilargia.egdx.logicbricks.component.game.TextureView in project Entitas-Java by Rubentxu.

the class ActuatorEntity method replaceTextureActuator.

public ActuatorEntity replaceTextureActuator(Bounds bounds, int opacity, Boolean flipX, Boolean flipY, Color tint) {
    TextureActuator component = (TextureActuator) recoverComponent(ActuatorComponentsLookup.TextureActuator);
    if (component == null) {
        component = new TextureActuator(bounds, opacity, flipX, flipY, tint);
    } else {
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            TextureView view = owner.getTextureView();
            if (bounds != null)
                view.bounds = bounds;
            if (flipX != null)
                view.flipX = flipX;
            if (flipY != null)
                view.flipY = flipY;
            if (opacity != -1)
                view.opacity = opacity;
            if (tint != null)
                view.tint = tint;
        };
    }
    replaceComponent(ActuatorComponentsLookup.TextureActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) TextureActuator(ilargia.egdx.logicbricks.component.actuator.TextureActuator)

Example 4 with TextureView

use of ilargia.egdx.logicbricks.component.game.TextureView in project Entitas-Java by Rubentxu.

the class GameEntity method replaceTextureView.

public GameEntity replaceTextureView(TextureRegion texture, Bounds bounds, boolean flipX, boolean flipY, float opacity, int layer, Color tint) {
    TextureView component = (TextureView) recoverComponent(GameComponentsLookup.TextureView);
    if (component == null) {
        component = new TextureView(texture, bounds, flipX, flipY, opacity, layer, tint);
    } else {
        component.texture = texture;
        component.bounds = bounds;
        component.flipX = flipX;
        component.flipY = flipY;
        component.opacity = opacity;
        component.layer = layer;
        component.tint = tint;
    }
    replaceComponent(GameComponentsLookup.TextureView, component);
    return this;
}
Also used : TextureView(ilargia.egdx.logicbricks.component.game.TextureView)

Example 5 with TextureView

use of ilargia.egdx.logicbricks.component.game.TextureView in project Entitas-Java by Rubentxu.

the class TextureRendererSystem method render.

@Override
public void render() {
    batch.setProjectionMatrix(cam.combined);
    batch.begin();
    for (GameEntity e : groupTextureView.getEntities()) {
        TextureView view = e.getTextureView();
        Body body = e.getRigidBody().body;
        processTextureFlip(view);
        batch.setColor(1f, 1f, 1f, 1f);
        if (view.opacity < 1)
            batch.setColor(1f, 1f, 1f, view.opacity);
        batch.draw(view.texture, body.getPosition().x - view.bounds.extentsX, body.getPosition().y - view.bounds.extentsY, view.bounds.extentsX, view.bounds.extentsY, view.bounds.extentsX * 2, view.bounds.extentsY * 2, 1, 1, MathUtils.radiansToDegrees * body.getTransform().getRotation());
    }
    for (ActuatorEntity e : groupEffect.getEntities()) {
        if (e.getLink().isOpen) {
            ParticleEffectActuator effectActuator = e.getParticleEffectActuator();
            effectActuator.particleEffect.draw(batch);
        }
    }
    batch.end();
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) ParticleEffectActuator(ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) Body(com.badlogic.gdx.physics.box2d.Body) ActuatorEntity(ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)

Aggregations

TextureView (ilargia.egdx.logicbricks.component.game.TextureView)7 GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)5 TextureActuator (ilargia.egdx.logicbricks.component.actuator.TextureActuator)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Vector3 (com.badlogic.gdx.math.Vector3)1 Body (com.badlogic.gdx.physics.box2d.Body)1 ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)1 Animations (ilargia.egdx.logicbricks.component.game.Animations)1 RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)1 ActuatorEntity (ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)1