Example usage for com.badlogic.gdx.scenes.scene2d.actions ColorAction setEndColor

List of usage examples for com.badlogic.gdx.scenes.scene2d.actions ColorAction setEndColor

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.actions ColorAction setEndColor.

Prototype

public void setEndColor(Color color) 

Source Link

Document

Sets the color to transition to.

Usage

From source file:actors.BasicSkel.java

public BasicSkel(float hlth, float dmg, float x, float y, int lvl, int pth, Stage stg, PlayScreen scrn) {

    this.setName("skeleton");
    level = lvl;/*from  www .  j a va 2 s. com*/
    path = pth;
    stage = stg;
    screen = scrn;
    health = hlth;
    damage = dmg;
    slowTimer = -1;
    slowed = false;
    reset = false;
    poisoned = false;
    notmoving = false;
    if (damage < 220)
        texture = new Texture("skelsword1.png");
    if (damage < 240 && damage >= 220)
        texture = new Texture("skelsword2.png");
    if (damage >= 240)
        texture = new Texture("skelsword3.png");
    sprite = new Sprite(texture);
    sprite.setScale(0.65f);
    setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight());

    fireEffect = new ParticleEffect();
    fireEffect.load(Gdx.files.internal("fire"), Gdx.files.internal(""));
    fireEffect.getEmitters().first().setPosition(getX(), getY());
    fireballSound = Gdx.audio.newSound(Gdx.files.internal("fireball.wav"));

    iceEffect = new ParticleEffect();
    iceEffect.load(Gdx.files.internal("ice"), Gdx.files.internal(""));
    iceEffect.getEmitters().first().setPosition(getX(), getY());

    poisonEffect = new ParticleEffect();
    poisonEffect.load(Gdx.files.internal("poison"), Gdx.files.internal(""));
    poisonEffect.getEmitters().first().setPosition(getX(), getY());

    emptyHealthBar = new Sprite(new Texture("emptyBar.png"));
    fullHealthBar = new Sprite(new Texture("fullBar.png"));

    ColorAction red = new ColorAction();
    red.setEndColor(Color.RED);
    red.setDuration(1f);
    MoveToAction moveOff = new MoveToAction();
    moveOff.setPosition(-100, -100);
    kill = new SequenceAction(red, moveOff);

    this.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (health != 100000 && abs(screen.player.getX() - getX()) < screen.playerRange
                    && abs(screen.player.getY() - getY()) < screen.playerRange) {
                if (screen.playerSpell == 1) {
                    health -= screen.playerDamage;
                    stage.addActor(
                            new Fireball(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16));
                    fireballSound.play(0.8f);
                    fireEffect.start();
                }
                if (screen.playerSpell == 2) {
                    health -= screen.playerDamage * 0.75;
                    stage.addActor(
                            new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16));
                    fireballSound.play(0.8f);
                    iceEffect.start();
                    slowTimer = 3;
                    if (health >= 0)
                        slowed = true;
                }
                if (screen.playerSpell == 3) {
                    poisoned = true;
                    stage.addActor(
                            new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16));
                    fireballSound.play(0.8f);
                    poisonEffect.start();
                }

            }
            if (health <= 0) {
                poisoned = false;
                setName("dead");
                health = 100000;
                clearActions();
                addAction(kill);
                screen.skeletonDeath.play(1.0f);
                screen.addGold(5);
            }
        }
    });

    velocity = 70;
    //Rectangle body = new Rectangle(getX(), getY(), getWidth(), getHeight());
    //ScaleByAction sba = new ScaleByAction();
    //sba.setAmount(0.25f);

    assignMovement(x, y);

}