当前位置: 首页>>代码示例>>Java>>正文


Java Screen类代码示例

本文整理汇总了Java中com.badlogic.gdx.Screen的典型用法代码示例。如果您正苦于以下问题:Java Screen类的具体用法?Java Screen怎么用?Java Screen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Screen类属于com.badlogic.gdx包,在下文中一共展示了Screen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.badlogic.gdx.Screen; //导入依赖的package包/类
@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);
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:18,代码来源:CatanGame.java

示例2: ShareScoreScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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();
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:22,代码来源:ShareScoreScreen.java

示例3: setScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
/**
 * 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();
			}
		});
	}
}
 
开发者ID:CherokeeLanguage,项目名称:cll1-gdx,代码行数:22,代码来源:AbstractGame.java

示例4: previousScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
/**
 * 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();
		}
	});
}
 
开发者ID:CherokeeLanguage,项目名称:cll1-gdx,代码行数:23,代码来源:AbstractGame.java

示例5: setPreviousScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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;


}
 
开发者ID:mrDarkHouse,项目名称:GDefence,代码行数:24,代码来源:GDefence.java

示例6: leaveAnimation

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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);

    }
 
开发者ID:msk610,项目名称:Chemtris,代码行数:27,代码来源:Levels.java

示例7: leaveAnimation

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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);

    }
 
开发者ID:msk610,项目名称:Chemtris,代码行数:18,代码来源:ElementLevels.java

示例8: onReceiveUnreliableTournamentCustomMessage

import com.badlogic.gdx.Screen; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:Nextpeer,项目名称:SkiFun,代码行数:26,代码来源:SkiFun.java

示例9: setScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
/** 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());

}
 
开发者ID:digital-thinking,项目名称:libgdx-transitions,代码行数:29,代码来源:FadingGame.java

示例10: makeMenuButton

import com.badlogic.gdx.Screen; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:gabrielsr,项目名称:bomberman-libgdx,代码行数:30,代码来源:MenuButtonFactory.java

示例11: processTouch

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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);
}
 
开发者ID:AlanMorel,项目名称:chainball,代码行数:19,代码来源:Game.java

示例12: navigateToLevel

import com.badlogic.gdx.Screen; //导入依赖的package包/类
@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");
	}
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:21,代码来源:NavigationManagerImpl.java

示例13: create

import com.badlogic.gdx.Screen; //导入依赖的package包/类
@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);
}
 
开发者ID:saltares,项目名称:ludumdare-29,代码行数:18,代码来源:LudumDare.java

示例14: create

import com.badlogic.gdx.Screen; //导入依赖的package包/类
@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);
}
 
开发者ID:caranha,项目名称:spacedebris,代码行数:21,代码来源:GdxGameMain.java

示例15: setScreen

import com.badlogic.gdx.Screen; //导入依赖的package包/类
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();
		}
	}
}
 
开发者ID:nrv,项目名称:BASToD,代码行数:23,代码来源:AbstractGame.java


注:本文中的com.badlogic.gdx.Screen类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。