LibGDX Scene2d操作影响多个参与者
我正在开发我的第二个应用程序,到目前为止进展得相当顺利。但现在我遇到了一个我无法找到解决方案的问题 我一直在使用scene2d舞台来展示一切。现在,我添加了一个黑色图像,每当调用新屏幕时(作为过渡),该图像就会淡出 我的问题是,当我将淡出动作添加到我的黑色图像时,它也会淡出背景。有趣的是,只有背景受到影响,没有其他演员受到影响 我试着改变演员的顺序,把他们分成小组,清除背景中的所有动作,把他的alpha值设为1,但没有任何效果 谢谢你帮助我 背景:LibGDX Scene2d操作影响多个参与者,libgdx,action,actor,stage,scene2d,Libgdx,Action,Actor,Stage,Scene2d,我正在开发我的第二个应用程序,到目前为止进展得相当顺利。但现在我遇到了一个我无法找到解决方案的问题 我一直在使用scene2d舞台来展示一切。现在,我添加了一个黑色图像,每当调用新屏幕时(作为过渡),该图像就会淡出 我的问题是,当我将淡出动作添加到我的黑色图像时,它也会淡出背景。有趣的是,只有背景受到影响,没有其他演员受到影响 我试着改变演员的顺序,把他们分成小组,清除背景中的所有动作,把他的alpha值设为1,但没有任何效果 谢谢你帮助我 背景: public class Background
public class BackgroundColor extends Actor {
public BackgroundColor(int x) {
this.setBounds(x, 0, 270, 960);
}
public void act(float delta) {
}
public void draw(Batch batch, float alpha) {
batch.draw(image, this.getX(), this.getY(), this.getWidth(), this.getHeight());
}
}
对于屏幕:
public class GameScreen implements Screen {
public Stage stage;
public BackgroundColor backgroundColor;
public Image black;
public GameScreen() {
stage = new Stage(new ExtendViewport(540, 900, 540, 960));
Gdx.input.setInputProcessor(stage);
setupStage();
}
private void setupStage() {
backgroundColor = new BackgroundColor(0);
stage.addActor(backgroundColor);
//this is the black layer
black = new Image(AssetLoader.black);
black.setBounds(0, 0, stage.getWidth(), stage.getHeight());
stage.addActor(black);
black.addAction(Actions.sequence(Actions.fadeOut((float)0.5), Actions.touchable(null)));
}
@Override
public void show() {
}
@Override
public void render(float deltaTime) {
Gdx.gl.glClear(0);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
所以,我有点明白了 显然,将不同的图像作为舞台的第一层解决了这个问题 我在
backgroundColor=newbackgroundcolor(0)之前添加了一个随机图像代码>这就解决了它
我还是不知道是什么原因,也许我错过了什么
如果你能告诉我这里发生了什么就好了
干杯你是如何在背景色课程中获得图像变量的?我的意思是:batch.draw(image,this.getX()…
image
只是我以前加载的静态纹理区域的一个替代品。请显示一个用于加载纹理的代码,我使用image=new纹理(Gdx.files.internal(“image.png”);
。我的意思是整个代码:)最好是背景色的完整代码,以及游戏屏幕作为问题的更新