现象:
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