Java Code Examples for com.watabou.noosa.Game#scene()

The following examples show how to use com.watabou.noosa.Game#scene() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExitButton.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.instance.finish();
	} else {
		YetAnotherPixelDungeon.switchNoFade(TitleScene.class);
	}
}
 
Example 2
Source File: ExitButton.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.instance.finish();
	} else {
		ShatteredPixelDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 3
Source File: ExitButton.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.instance.finish();
	} else {
		PixelDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 4
Source File: ExitButton.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.instance.finish();
	} else {
		ShatteredPixelDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 5
Source File: PixelScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void showBadge(Badges.Badge badge) {
	if(!(Game.scene() instanceof GameScene)) {
		return;
	}
	
	if (uiCamera != null && !Game.isPaused()) {
		BadgeBanner banner = BadgeBanner.show(badge.image);
		banner.camera = uiCamera;
		banner.x = align(banner.camera,
				(banner.camera.width - banner.width) / 2);
		banner.y = align(banner.camera,
				(banner.camera.height - banner.height) / 3);
		Game.addToScene(banner);
	}
}
 
Example 6
Source File: InterlevelScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static public void Do(InterlevelScene.Mode mode) {

        if(Game.scene() instanceof GameScene && Dungeon.level!=null && Dungeon.hero!=null) { // not game start
            Dungeon.hero.getSprite().completeForce();
            for(Mob mob:Dungeon.level.getCopyOfMobsArray()) {
                mob.getSprite().completeForce();
            }
        }

        InterlevelScene.mode = mode;
        Game.switchScene(InterlevelScene.class);
    }
 
Example 7
Source File: ExitButton.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.shutdown();
	} else {
		RemixedDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 8
Source File: ExitButton.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.instance.finish();
	} else {
		ShatteredPixelDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 9
Source File: BadgesScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {

	super.create();

	Music.INSTANCE.play( Assets.THEME, true );
	Music.INSTANCE.volume( 1f );

	uiCamera.visible = false;

	int w = Camera.main.width;
	int h = Camera.main.height;

	Archs archs = new Archs();
	archs.setSize( w, h );
	add( archs );

	int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
	int ph = h - 30;

	NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
	panel.size( pw, ph );
	panel.x = (w - pw) / 2;
	panel.y = (h - ph) / 2;
	add( panel );

	BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
	title.hardlight( Window.TITLE_COLOR );
	title.measure();
	title.x = align( (w - title.width()) / 2 );
	title.y = align( (panel.y - title.baseLine()) / 2 );
	add( title );

	Badges.loadGlobal();

	ScrollPane list = new BadgesList( true );
	add( list );

	list.setRect(
			panel.x + panel.marginLeft(),
			panel.y + panel.marginTop(),
			panel.innerWidth(),
			panel.innerHeight() );

	ExitButton btnExit = new ExitButton();
	btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
	add( btnExit );

	fadeIn();

	Badges.loadingListener = new Callback() {
		@Override
		public void call() {
			if (Game.scene() == BadgesScene.this) {
				ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
			}
		}
	};
}
 
Example 10
Source File: BadgesScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	Music.INSTANCE.play( Assets.THEME, true );
	Music.INSTANCE.volume( 1f );
	
	uiCamera.visible = false;
	
	int w = Camera.main.width;
	int h = Camera.main.height;
	
	Archs archs = new Archs();
	archs.setSize( w, h );
	add( archs );
	
	int pw = (int)Math.min( w, (PixelDungeon.landscape() ? MIN_WIDTH_L : MIN_WIDTH_P) * 3 ) - 16;
	int ph = (int)Math.min( h, (PixelDungeon.landscape() ? MIN_HEIGHT_L : MIN_HEIGHT_P) * 3 ) - 32;
	
	float size = (float)Math.sqrt( pw * ph / 27f );
	int nCols = (int)Math.ceil( pw / size );
	int nRows = (int)Math.ceil( ph / size );
	size = Math.min( pw / nCols, ph / nRows );
	
	float left = (w - size * nCols) / 2;
	float top = (h - size * nRows) / 2;
	
	BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
	title.hardlight( Window.TITLE_COLOR );
	title.measure();
	title.x = align( (w - title.width()) / 2 );
	title.y = align( (top - title.baseLine()) / 2 );
	add( title );
	
	Badges.loadGlobal();
	
	List<Badges.Badge> badges = Badges.filtered( true );
	for (int i=0; i < nRows; i++) {
		for (int j=0; j < nCols; j++) {
			int index = i * nCols + j;
			Badges.Badge b = index < badges.size() ? badges.get( index ) : null;
			BadgeButton button = new BadgeButton( b );
			button.setPos(
				left + j * size + (size - button.width()) / 2,
				top + i * size + (size - button.height()) / 2);
			add( button );
		}
	}
	
	ExitButton btnExit = new ExitButton();
	btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
	add( btnExit );
	
	fadeIn();
	
	Badges.loadingListener = new Callback() {
		@Override
		public void call() {
			if (Game.scene() == BadgesScene.this) {
				PixelDungeon.switchNoFade( BadgesScene.class );
			}
		}
	};
}