zoukankan      html  css  js  c++  java
  • 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);
        }
    }
  • 相关阅读:
    ES2017中的修饰器Decorator
    ES6中的模块
    代理(Proxy)和反射(Reflection)
    ES2017中的async函数
    ES6数字扩展
    Promise和异步编程
    ES6定型数组
    ES6数组扩展
    ES6中的类
    ES6中的Set和Map集合
  • 原文地址:https://www.cnblogs.com/cuizhf/p/3978237.html
Copyright © 2011-2022 走看看