2013-04-13 2 views
3

Я хочу анимированные заставки, как замирание в исчезать из за которые я делаю в методе изменения размера следующегоscene2D в libgdx -Animation не работает

public class SplashScreen extends GamePlayScreen { 

@Override 
public void resize(int width, int height) { 
    super.resize(width, height); 
    stage.clear(); 
    Drawable splashDrawable = new TextureRegionDrawable(region); 
    splashImage = new Image(splashDrawable, Scaling.stretch); 
    splashImage.setFillParent(true); 
    splashImage.getColor().a = 0f; 
    splashImage.addAction(Actions.sequence(Actions.fadeIn(0.75f), 
      Actions.delay(1.75f), Actions.fadeOut(0.75f), 
      new Action() { 
       @Override 
       public boolean act(float delta) { 
        // the last action will move to the next screen 
        System.out.println("moving to next screen"); 
        splashGameObj.setScreen(new GamePlayScreen(
          splashGameObj)); 
        return true; 
       } 
      })); 
    stage.addActor(splashImage); 
    } 
} 

ответ

2

Declare эта переменная

private Stage stage;  

@Override 
public void render(float delta) { 
    // TODO Auto-generated method stub 
    update(); 
    draw(delta); 
} 

private void draw(float delta) { 
    // TODO Auto-generated method stub 
    Gdx.gl.glClearColor(1, 1, 1, 1); 
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); 

    stage.act(delta); 
    stage.draw() 
} 

@Override 
public void resize(int width, int height) { 
    stage.setViewport(width, height, true); 

} 

@Override 
public void show() { 
    // TODO Auto-generated method stub 
    stage = new Stage(); 
    Gdx.input.setInputProcessor(stage); 

    Image splashImage = new Image(region); 
    splashImage.addAction(Actions.sequence(Actions.fadeOut(0.0001f), Actions.fadeIn(5f), 
      Actions.run(onSplashFinishedRunnable))); 



    stage.addActor(splashImage); 
} 

Runnable onSplashFinishedRunnable = new Runnable() { 

    @Override 
    public void run() { 
     // TODO Auto-generated method stub 
     splashGameObj.setScreen(new GamePlayScreen(splashGameObj)); 
    } 
}; 
3

Попробуйте изменить new Action() к new RunnableAction(){ public void run(){.....

Herer - это больше действий и другое объяснение того, как они работают. обратитесь к другому вопросу.
->Actions
Также обратите внимание на:
screen2D, libgdx wiki about actions

+0

Я понимаю ... Спасибо @Benjamin –

+0

ваш Wellcome :) – BennX

+0

ли тело говорит о том, как можно применить больше анимаций, кроме fade in fade out в libgdx .. Потому что все, что я пробовал, не соответствовало значению ... :( –