egordorichev / LastTry

:deciduous_tree: LastTry is open-source game written in Java, using LibGDX library and inspired by Terraria :deciduous_tree:
MIT License
119 stars 17 forks source link

Attacking enemies causes textures to be tinted #68

Closed Col-E closed 7 years ago

Col-E commented 7 years ago

Img

Attacking slimes causes the player (and sometimes other GUI textures such as the hearts) to be random colors. Seems like the only colors as of right now are: Green, Yellow, Red.

Col-E commented 7 years ago

Found the issue source:

Creature.renderHealthBar()

        if (hp < 0.3f) {
            Graphics.batch.setColor(1, 0, 0, 1);
        } else if (hp < 0.6f) {
            Graphics.batch.setColor(1, 1, 0, 1);
        } else {
            Graphics.batch.setColor(0, 1, 0, 1);
        }

This seems to be applying to the player and not the slimes from the pic.

Fixed by the following:

    @Override
    public void render() {
        // Reset color in case last entity was damaged.
        Graphics.batch.setColor(1, 1, 1, 1);

        // super.render(); // old placement
        if (this.stats.getHp() != this.stats.getMaxHP() && this.stats.getHp() != 0) {
            this.renderHealthBar();
        }
        // new placement
        super.render();
    }
Col-E commented 7 years ago

Closed in pull https://github.com/egordorichev/LastTry/pull/71