Java 类com.badlogic.gdx.Screen 实例源码

项目:Catan    文件:CatanGame.java   
@Override
public void create() {
    batch = new SpriteBatch();

    // Load the UI skin
    skin = new Skin(Gdx.files.internal("skin/uiskin.json"));

    clickSound = Gdx.audio.newSound(Gdx.files.internal("sound/buttonClick.mp3"));
    menuMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/menuMusic.mp3"));
    menuMusic.setLooping(true);

    // Load the current account if cached
    account = AccountManager.getLocalAccount();
    // The first screen that shows up when the game starts
    Screen mainScreen = account == null ? new LoginScreen(this) : new MenuScreen(this);
    setScreen(mainScreen);
}
项目:Klooni1010    文件:ShareScoreScreen.java   
ShareScoreScreen(final Klooni game, final Screen lastScreen,
                 final int score, final boolean timeMode) {
    this.game = game;
    this.lastScreen = lastScreen;

    this.score = score;
    this.timeMode = timeMode;

    final Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    infoLabel = new Label("Generating image...", labelStyle);
    infoLabel.setColor(Klooni.theme.textColor);
    infoLabel.setAlignment(Align.center);
    infoLabel.layout();
    infoLabel.setPosition(
            (Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
            (Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);

    spriteBatch = new SpriteBatch();
}
项目:cll1-gdx    文件:AbstractGame.java   
/**
 * Replaces the top of the "deck" of screens with this screen.<br/>
 * Current screen (if any) {@link Screen#hide()} is called.<br/>
 * New screen {@link Screen#show()} is called.<br/>
 * Previous screen (if any) {@link Screen#dispose()} is called.
 */
@Override
public void setScreen(Screen screen) {
    int activeScreen = screens.size() - 1;
    screens.add(screen);
    super.setScreen(screen);
    if (activeScreen > -1) {
        final Screen forDisposal = screens.remove(activeScreen);
        Gdx.app.postRunnable(new Runnable() {
            @Override
            public void run() {
                forDisposal.dispose();
            }
        });
    }
}
项目:cll1-gdx    文件:AbstractGame.java   
/**
 * Discards current screen and displays previous screen.<br/>
 * Has no effect if there is no previous screen to go back to.
 */
public void previousScreen() {
    if (screens.size() < 2) {
        return;
    }
    // remove current screen from "deck"
    final Screen forRemoval = screens.remove(screens.size() - 1);
    // hide it
    forRemoval.hide();
    // show new "top" screen
    super.setScreen(screens.get(screens.size() - 1));
    // schedule for dispose the no longer shown screen
    Gdx.app.postRunnable(new Runnable() {
        @Override
        public void run() {
            forRemoval.dispose();
        }
    });
}
项目:GDefence    文件:GDefence.java   
public Screen setPreviousScreen(){
    Screen currentScreen = getScreen();
    if(currentScreen instanceof CampainMap){//only in back button
           GDefence.getInstance().user.save();
           GDefence.getInstance().user.flush();//empty user info in main menu
        setScreen(campainChoose);
    }else if(currentScreen instanceof OptionScreen){
        setScreen(mainMenu);
    }else if(currentScreen instanceof CampainChoose){
        setScreen(mainMenu);
    }else if(currentScreen instanceof Arsenal){
        setScreen(campainMap);
    }else if(currentScreen instanceof Store){
        setScreen(campainMap);
    }else if(currentScreen instanceof Smith){
        setScreen(campainMap);
    }else if(currentScreen instanceof LevelPreparationScreen){
        setScreen(campainMap);
    }
    return null;


}
项目:Chemtris    文件:Levels.java   
private void leaveAnimation(final Screen setScreen){

        //setup a parallel event
        Timeline.createParallel().beginParallel()
                .push(Tween.to(heading, ActorAccessor.Y, 2f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level1, ActorAccessor.Y, 1.5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level2, ActorAccessor.Y, 1.5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level3, ActorAccessor.Y, 1.5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level4, ActorAccessor.Y, 1f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level5, ActorAccessor.Y, 1f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level6, ActorAccessor.Y, 1f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l1, ActorAccessor.Y, 1.25f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l2, ActorAccessor.Y, 1.25f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l3, ActorAccessor.Y, 1.25f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l4, ActorAccessor.Y, .75f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l5, ActorAccessor.Y, .75f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l6, ActorAccessor.Y, .75f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(more, ActorAccessor.Y, .5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l7, ActorAccessor.Y, .5f).target(-Gdx.graphics.getHeight())).end().setCallback(new TweenCallback() {
            @Override
            public void onEvent(int type, BaseTween<?> source) {
                ((Game)Gdx.app.getApplicationListener()).setScreen(setScreen);
            }
        }).start(tweenManager);

    }
项目:Chemtris    文件:ElementLevels.java   
private void leaveAnimation(final Screen setScreen){

        //setup a parallel event
        Timeline.createParallel().beginParallel()
                .push(Tween.to(heading, ActorAccessor.Y, 2f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level1, ActorAccessor.Y, 1.5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l1, ActorAccessor.Y, 1.25f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(level2, ActorAccessor.Y, 1.5f).target(-Gdx.graphics.getHeight()))
                .push(Tween.to(l2, ActorAccessor.Y, 1.25f).target(-Gdx.graphics.getHeight()))
                .end().setCallback(new TweenCallback() {
            @Override
            public void onEvent(int type, BaseTween<?> source) {
                ((Game)Gdx.app.getApplicationListener()).setScreen(setScreen);
            }
        }).start(tweenManager);

    }
项目:SkiFun    文件:SkiFun.java   
@Override
public void onReceiveUnreliableTournamentCustomMessage(NextpeerTournamentCustomMessage message) {

    try
    {
        Screen screen = SkiFun.this.getScreen();
        if (screen==null)
            return;
        // Act only if the current scene is the game screen
        if (screen instanceof GameScreen) {
            GameScreen gameScreen = (GameScreen)screen;

            // Pass the received data to the world instance which responsible on the game updates
            if (message==null)
                return;
            if (gameScreen.world==null)
                return;
            gameScreen.world.onReceiveTournamentCustomMessage(message);
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}
项目:libgdx-transitions    文件:FadingGame.java   
/** Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new
 * screen, if any.
 * @param screen may be {@code null} */
@Override
public void setScreen(Screen screen) {
    screen.show();
    if (transitionRunning)
        Gdx.app.log(FadingGame.class.getSimpleName(), "Changed Screen while transition in progress");
    if (this.screen == null) {
        this.screen = screen;
    } else {
        if (screenTransition == null) {
            this.screen.hide();
            this.screen = screen;
        } else {
            this.nextScreen = screen;
            this.screen.pause();
            this.nextScreen.pause();
            currentTransitionTime = 0;
            transitionRunning = true;
            notifyStarted();
        }

    }

    this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}
项目:bomberman-libgdx    文件:MenuButtonFactory.java   
/**
 * Build a new TextButton with factory default button style
 * 
 * @param context
 *            a Game context where
 * @param label
 *            string button's label
 * @param nextScreenAfterClick
 *            the next screen that will be showed after button click
 * @return a new TextButton ready to be added to a stage
 */
public TextButton makeMenuButton(final Game game, final String label,
        final Screen nextScreenAfterClick) {
    button = new TextButton(label, textButtonStyle);
    button.setHeight(menuItemHeight);
    button.setWidth(menuItemWidth);
    button.setPosition(initPosXMenu, initPosYMenu - menuItemHeight
            * menuItemNumber);
    menuItemNumber++;
    button.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Assets.playSound(Assets.clickSound);
            game.getScreen().dispose();
            game.setScreen(nextScreenAfterClick);
        }
    });
    return button;
}
项目:chainball    文件:Game.java   
public void processTouch(float x, float y) {
    if (balls.isTouched(x, y)){
        incrementChainLength();
        Ball ball = balls.getTouchedBall(x, y);
        ball.playSound(Constants.VOLUME);
        updateScore(ball);
        lines.addCurrentLine(ball);
        ball.touch();
        if (ball.getType() == BallType.GRAY){
            Gdx.input.vibrate(Constants.VIBRATION_DURATION);
            Screen gameOver = new GameOver(balls, lines, offset, score, longestChain, stopwatch.getElapsedTimeSecs());
            Chainball.setScreen(gameOver);
        } else if (ball.getType() == BallType.RED){
            Gdx.input.vibrate(Constants.VIBRATION_DURATION);
        } 
    }
    lines.updateCurrentLine(x, y);
}
项目:HAW-SE2-projecthorse    文件:NavigationManagerImpl.java   
@Override
public final void navigateToLevel(final String levelID) {
    Gdx.app.log("NavigationManager", "NavigateToLevel");
    try {
        if (game.getScreen() != null) {
            InputManager.clear();
            game.getScreen().dispose();
            game.setScreen(null);
        }
        if (levelIDHistory.isEmpty() || !levelIDHistory.peek().equals(levelID)) {
            levelIDHistory.push(levelID);
        }
        Screen screen = levelManager.getScreenByLevelID(levelID);
        game.setScreen(screen);

    } catch (LevelLoadException e) {
        e.printStackTrace();
        navigateToLevel("worldmap");
    }
}
项目:ludumdare-29    文件:LudumDare.java   
@Override
public void create () {
    Env.init(this);

    camera = new OrthographicCamera();
    viewport = new ExtendViewport(960, 720, 1280, 720, camera);
    assets = new Assets();

    tweenManager = new TweenManager();
    Tween.setCombinedAttributesLimit(4);
    Tween.registerAccessor(Actor.class, new ActorTweener());

    screens = new ObjectMap<Class<? extends Screen>, Screen>();
    screens.put(GameScreen.class, new GameScreen());

    setScreen(GameScreen.class);
}
项目:spacedebris    文件:GdxGameMain.java   
@Override
public void create() {      
    screenlist = new Screen[SCREEN_NUMBER];
    screenlist[SCREEN_SPLASH] = new SplashScreen(SCREEN_SPLASH);
    screenlist[SCREEN_BATTLE] = new BattleScreen();

    // Creating global resource managers
    queueAssets();
    animman = new AnimationManager();

    setScreen(screenlist[SCREEN_SPLASH]);

    nextscreen = SCREEN_SPLASH;
    changescreen = false;

    debugtext = new BitmapFont();
    batch = new SpriteBatch();

    Gdx.app.setLogLevel(Application.LOG_DEBUG);
}
项目:BASToD    文件:AbstractGame.java   
public void setScreen(AbstractScreen screen) {
    if (screen.isCached()) {
        screensCache.put(screen.getCacheName(), screen);
    }

    if (!screen.isStarted()) {
        screen.start();
    }

    Gdx.input.setInputProcessor(screen);

    Screen current = getScreen();

    super.setScreen(screen);

    if (current != null) {
        AbstractScreen currentScreen = (AbstractScreen) current;
        if (!currentScreen.isCached()) {
            currentScreen.stop();
        }
    }
}
项目:it.alcacoop.fourinaline    文件:FourInALine.java   
@Override
public void setScreen(final Screen screen) {
  System.out.println("SET SCREEN");
  if (currentScreen != null) {
    ((BaseScreen)screen).initialize();
    currentScreen.fadeOut();
    TimerTask task = new TimerTask() {
      @Override
      public void run() {
        FourInALine.super.setScreen(screen);
      }
    };
    transitionTimer.schedule(task, (long)(currentScreen.animationTime * 1000));
  } else
    super.setScreen(screen);
  currentScreen = (BaseScreen)screen;
}
项目:ProjektGG    文件:ProjektGG.java   
@Override
public final void dispose() {
    this.screen = null;
    for (Screen s : screens.values()) {
        s.pause();
        s.dispose();
    }

    this.batch.dispose();
}
项目:Catan    文件:CreateScreen.java   
public CreateScreen(CatanGame pGame, Screen parentScreen) {
    this.parentScreen = parentScreen;
    game = pGame;
    boardHexes = new ArrayList<>();
    boardOrigin = new MutablePair<>();
    setupBoardOrigin(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}
项目:Snakies    文件:MainGame.java   
@Override
public void create () {
    VisUI.load();

    screens = new Stack<Screen>();
    pushScreen(new HostOrJoinScreen(this));
}
项目:odb-artax    文件:TransitionSystem.java   
/**
 * Transition to screen after delay in seconds.
 */
public void transition(Class<? extends Screen> screen, float delay) {
    E()
            .script(
                    sequence(
                            delay(seconds(delay)),
                            add(new Transition(screen))
                    )
            );
}
项目:penguins-in-space    文件:ScorePresenter.java   
public ScorePresenter(final Asteroids game, final Screen parent, List<PlayerData> playerData) {
    this.parent = parent;
    this.game = game;
    this.playerData = playerData;
    this.view = new ScoreView(game.getBatch(), new ViewHandler());
    Collections.sort(playerData, new Comparator<PlayerData>() {
        @Override
        public int compare(PlayerData s, PlayerData t1) {
            return t1.totalScore - s.totalScore;
        }
    });
}
项目:penguins-in-space    文件:SettingsPresenter.java   
SettingsPresenter(final Asteroids game, final Screen parent) {
    this.parent = parent;
    this.game = game;
    this.view = new SettingsView(game.getBatch(), new ViewHandler());
    this.audioService = ServiceLocator.getAppComponent().getAudioService();
    this.settingsService = ServiceLocator.appComponent.getSettingsService();
    musicVolume = settingsService.getInt(ISettingsService.MUSIC_VOLUME, 100);
}
项目:penguins-in-space    文件:BaseGamePresenter.java   
BaseGamePresenter(Asteroids game, Screen parent) {
    this.parent = parent;
    this.game = game;
    engine = new PooledEngine();
    initializeEntityComponent(engine);
    controllerInputHandler = new ControllerInputHandler(engine);
    setupView();
    setupWorld();
    setupEngine(engine, game.getBatch());
    world.run();
}
项目:Klooni1010    文件:TransitionScreen.java   
public TransitionScreen(Klooni game, Screen from, Screen to, boolean disposeAfter) {
    this.disposeAfter = disposeAfter;
    this.game = game;
    fromScreen = from;
    toScreen = to;

    spriteBatch = new SpriteBatch();
}
项目:gdx-cclibs    文件:ExampleRunner.java   
public void exitCurrentExample (){
    Screen exitedScreen = getScreen();
    setScreen(menuScreen);
    if (exitedScreen != null)
        exitedScreen.dispose();
    selectBox.setSelected(((Example)exitedScreen).getClass());
}
项目:gdx-cclibs    文件:ExampleRunner.java   
@Override
public void dispose (){
    Screen exitedScreen = getScreen();
    if (exitedScreen != null)
        exitedScreen.dispose();
    setScreen(null);
    spriteBatch.dispose();
    skin.dispose();
}
项目:arcadelegends-gg    文件:ScreenManager.java   
/**
 * Registers the given screen into the {@link ScreenManager}.
 * Initializes the given {@link Screen} with a default constructor, if init is true.
 *
 * @param type type of the {@link Screen}
 * @return the old registered instance
 */
public synchronized <T extends Screen> T register(Class<T> type) {
    if (screenMap.containsKey(type))
        throw new IllegalArgumentException("Screen already registerd: " + ClassReflection.getSimpleName(type));
    T screen = null;
    try {
        screen = ClassReflection.newInstance(type);
    } catch (ReflectionException e) {
        throw new IllegalArgumentException(e);
    }
    return (T) screenMap.put(type, screen);
}
项目:arcadelegends-gg    文件:ScreenManager.java   
public synchronized <T extends Screen> T get(Class<T> type, boolean init) {
    if (init && !isRegistered(type))
        register(type);
    if (!isRegistered(type))
        throw new IllegalArgumentException("Screen not registered: " + ClassReflection.getSimpleName(type));
    return (T) screenMap.get(type);
}
项目:arcadelegends-gg    文件:ScreenManager.java   
@Override
public synchronized void dispose() {
    for (Iterator<Map.Entry<Class<? extends Screen>, Screen>> iter = screenMap.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry<Class<? extends Screen>, Screen> entry = iter.next();
        entry.getValue().dispose();
        iter.remove();
    }
}
项目:Hackerman    文件:GameOverScreen.java   
public void draw() {
    game.batch.draw(gameOver, 231, 450, GAME_OVER_TEXT_WIDTH, GAME_OVER_TEXT_HEIGHT );
    if (Gdx.input.getX() < buttonX && Gdx.input.getX() > CENTER_X
            && Gdx.input.getY() > topY && Gdx.input.getY() < TOP_Y) {
        game.batch.draw(exitButtonActive, CENTER_X, 300, BUTTON_WIDTH, BUTTON_HEIGHT );
        if (Gdx.input.isTouched()) {
            game.gameScreen.setState(GameScreen.STATE.EXIT_YES);
            game.setScreen((Screen)game.getGameScreen());
        }
    } else {
        game.batch.draw(exitButtonInactive, CENTER_X, 300, BUTTON_WIDTH, BUTTON_HEIGHT);
    }
}
项目:SpaceGame    文件:SpaceGame.java   
/**
 * Set a screen and then dispose of the old screen
 *
 * This can be called from any thread
 *
 * @param screen - the new screen to switch to
 */
public void setScreenAndDisposeOld(Screen screen) {
    Gdx.app.postRunnable(() -> {
        Screen old = getScreen();
        setScreen(screen);
        old.dispose();
    });
}
项目:odb-little-fortune-planet    文件:TransitionSystem.java   
/**
 * Transition to screen after delay in seconds.
 */
public void transition(Class<? extends Screen> screen, float delay) {
    E()
            .script(
                    sequence(
                            delay(seconds(delay)),
                            add(new Transition(screen))
                    )
            );
}
项目:Onyx    文件:ScreenManager.java   
public static void setCurrentScreen(Screen currentScreen) {

        // Because GameScreen requires special disposing, we don't dispose it here.

        if (ScreenManager.currentScreen != null && ! (ScreenManager.currentScreen instanceof GameScreen)) ScreenManager.currentScreen.dispose();
        String name = currentScreen.getClass().getSimpleName();
        log.print("Changed screen to '%s'", name);
        ScreenManager.currentScreen = currentScreen;
    }
项目:odb-dynasty    文件:TransitionSystem.java   
/**
 * Transition to screen after delay in seconds.
 */
public void transition(Class<? extends Screen> screen, float delay) {
    E.create(world)
            .schedule(
                    sequence(
                            delay(seconds(delay)),
                            add(new Transition(screen))
                    )
            );
}
项目:Escapy    文件:EscapyGameScreen.java   
@Override
  public Screen initState(Object ... vars) {

int[] dim = new int[]{0, 0, super.SCREEN_DEFAULT_WIDTH, super.SCREEN_DEFAULT_HEIGHT};

      this.init_base(dim);
System.out.println(super.SCREEN_WIDTH+"::"+super.SCREEN_HEIGHT);

      super.initializationEnded = true;
this.resize(super.SCREEN_WIDTH, super.SCREEN_HEIGHT);
      System.gc();
      return this;
  }
项目:rbcgj-2016    文件:AbstractScreen.java   
public void setScreen(final Screen screen) {
    Gdx.input.setInputProcessor(null);
    fx.fadeOut(1f, TweenEquations.easeInQuad, new TweenCallback() {
        @Override
        public void onEvent(int type, BaseTween<?> source) {
            dispose();
            game.setScreen(screen);
        }
    });
}
项目:cll1-gdx    文件:AbstractGame.java   
@Override
public void dispose() {
    log("Dispose");
    super.dispose();
    for (Screen screen : screens) {
        screen.dispose();
    }
}
项目:Quilly-s-Castle    文件:QuillysCastleGame.java   
public Screen getScreen(ScreenType type) {
switch (type) {
    case MAIN_MENU:
    return mainMenuScreen;
    case NEW_GAME:
    return newGameScreen;
    case GAME:
    return mainGameScreen;
    case LOAD_GAME:
    return loadGameScreen;
}

return null;
   }
项目:123Dor    文件:ScreenManager.java   
public void showScreen(ScreenEnum screenEnum, Object... params) {

        // Get current screen to dispose it
        Screen currentScreen = game.getScreen();

        // Show new screen
        AbstractScreen newScreen = screenEnum.getScreen(params);
        newScreen.buildStage();
        game.setScreen(newScreen);

        // Dispose previous screen
        if (currentScreen != null) {
            currentScreen.dispose();
        }
    }
项目:Battle-City-Multiplayer    文件:CoreBC.java   
public static void changeScreen(Screen screen) {
    if (INSTANCE.getScreen() != null) {
        INSTANCE.getScreen().dispose();
    }

    INSTANCE.setScreen(screen);
    screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    if (screen instanceof InputAdapter) {
        Gdx.input.setInputProcessor((InputAdapter) screen);
    }
}