Libgdx window add alpha action change the background actor alpha

现象:

      Stage中包括一个Window,一个Actor,Window中加入alpha action后,Actor也随之消失;Actor加入alpha action后,不起作用。

解决:

      重写draw方法,加入batch.setColor(getColor().r, getColor().g, getColor().b, getColor().a);

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.secondegg.reversi.util.Assets;

/**
 *
 * @author cuizhf
 */
public class Table extends Actor {
    
    public Table() {
    }
    
    @Override
    public void act (float delta) {
        super.act(delta);
    }
    
    @Override
    public void draw (Batch batch, float parentAlpha) {
        batch.setColor(getColor().r, getColor().g, getColor().b, getColor().a);    
        batch.draw(Assets.instance.table.tableh, 0, 0);
        batch.draw(Assets.instance.table.tablen, 100, 0);
    }
}

 

Libgdx window add alpha action change the background actor alpha

上一篇:2021-8-25 All Paths From Source to Target


下一篇:左侧宽度固定,右侧充满剩余空间,有哪些实现方式?