我正在进行屏幕淡入和淡出过渡,目前我的舞台只包括背景图像和图像按钮(将来还会有一个按钮)。现在的问题是背景淡化工作,但不是图像按钮。任何想法我怎么能轻松"分组"所有的舞台都在一起,一下子消失了?这是我目前的代码:
public class MyActor extends Actor {
@Override
public void draw( SpriteBatch batch, float parentAlpha ) {
batch.setColor( 1, 1, 1, 1*parentAlpha );
batch.draw( AssetLoader.bg, 0, 0, ZBGame.VIRTUAL_WIDTH, ZBGame.VIRTUAL_HEIGHT );
batch.draw( AssetLoader.zbLogo,
ZBGame.VIRTUAL_WIDTH / 2-140,
ZBGame.VIRTUAL_HEIGHT-AssetLoader.zbLogo.getRegionHeight(),
AssetLoader.zbLogo.getRegionWidth(),
AssetLoader.zbLogo.getRegionHeight());
TextureAtlas buttons = new TextureAtlas( Gdx.files.internal("data/texture.txt") );
Skin skin = new Skin( buttons );
ImageButtonStyle btnStyle = new ImageButtonStyle();
btnStyle.up = skin.getDrawable("startBtn");
ImageButton button = new ImageButton(btnStyle);
button.addListener(new InputListener( ) {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
stage.addAction( Actions.sequence( Actions.fadeOut(.5f), Actions.run( new Runnable( ) {
@Override
public void run() {
game.setScreen(new OptionScreen( game ) );
}
}) ) );
return true;
}
stage.addActor(button);
}
}
@Override
public void show() {
stage = new Stage( );
Gdx.input.setInputProcessor(stage);
MyActor myActor = new MyActor( );
stage.addActor(myActor);
stage.addAction( Actions.sequence( Actions.alpha(0), Actions.fadeIn(1)) );
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
stage.act(delta);
stage.draw();
}