Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法阻止libgdx scene2d/ui/Label为半透明_Java_Android_Libgdx_Label_Scene2d - Fatal编程技术网

Java 无法阻止libgdx scene2d/ui/Label为半透明

Java 无法阻止libgdx scene2d/ui/Label为半透明,java,android,libgdx,label,scene2d,Java,Android,Libgdx,Label,Scene2d,无论我做什么,标签都是半透明的。 表中的标签(labelA、labelB、labelC)最初是0%透明的,但一旦您通过labelA.setText(“sometext”)设置了它们的文本,它们就会透明他们像他们的兄弟一样半透明labelWarning标签警告始终是半透明的。我曾尝试在没有组的情况下将其单独添加到stage(stage.addActor(labelWarning);),通过labelWarning.getColor()将其更改为a但没有区别!期待您的帮助 Label.Lab

无论我做什么,标签都是半透明的。 表中的标签(
labelA、labelB、labelC
)最初是0%透明的,但一旦您通过
labelA.setText(“sometext”)设置了它们的文本,它们就会透明他们像他们的兄弟一样半透明
labelWarning
<代码>标签警告
始终是半透明的。我曾尝试在没有组的情况下将其单独添加到stage(
stage.addActor(labelWarning);
),通过
labelWarning.getColor()将其更改为
a
但没有区别!期待您的帮助

    Label.LabelStyle ls=new 
    Label.LabelStyle(screenGame.getFont(),Color.BROWN);
    Label labelA=new Label("700 metre",ls);
    Label labelB=new Label("700 metre",ls);
    Label labelC=new Label("1500 metre",ls);

    labelWarning=new Label("sd",ls);
    labelWarning.setWrap(true);
    labelWarning.setPosition(50,30);
    labelWarning.setWidth(500);
    labelWarning.setAlignment(Align.top);

    tableEPS=new Table();
    //tableEPS.debug();

    tableEPS.row();
    tableEPS.add(epgrass).pad(10f);
    tableEPS.add(epdesert).pad(10f);
    tableEPS.add(epsnow).pad(10f);
    tableEPS.row();
    tableEPS.add(labelA);
    tableEPS.add(labelB);
    tableEPS.add(labelC);
    tableEPS.row();


    tableEPS.setFillParent(true);
    tableEPS.pack();

    episodesGroup=new Group();
    episodesGroup.setSize(worldwidth,worldheight);
    episodesGroup.addActor(imagebgclouds);
    episodesGroup.addActor(backbutton);
    episodesGroup.addActor(tableEPS);
    episodesGroup.addActor(labelWarning);

    stage=new Stage(screenGame.getViewport());

    stage.addActor(episodesGroup);

如果通过LabelStyle而不是标签本身更改颜色,则会发生这种情况。由于它们都共享同一个LabelStyle实例,因此更改样式将影响所有它们。通过调用
label.setColor()
确保正在更改颜色或alpha


标签的颜色与标签样式的颜色相乘,因此如果不想弄乱样式的色调,请使用
Label.setColor(1,1,1,alpha)

不起作用,我甚至在
labelWarning.setText(“sometext”)前后添加了
labelWarning.setColor(16,14,119,1)
,为
labelWarning
创建了不同的标签样式,仍然相同,半透明:(颜色的比例是0-1,而不是0-255。我按照你说的做了,再次没有帮助。但是我碰巧发现我用spriteBatch绘制的字体也是半透明的。但是,按照你说的设置颜色会使它们不透明,我必须在设置正常颜色后设置rgba颜色才能实现这一点。
batch.begin();font.setColor(color.WHITE);font.setColor(1,1,1,1.0f);font.draw(batch,“fps:+(int)(1f/delta),0,50);batch.end();
我添加了一行
font.setColor(1,1,1,1.0f);
如果没有这行,这个fps文本也是半透明的,
labelWarning
仍然是半透明的