com.watabou.noosa.audio.Music Java Examples
The following examples show how to use
com.watabou.noosa.audio.Music.
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: Game.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void onResume() { super.onResume(); now = 0; SystemTime.tick(); SystemTime.updateLastActionTime(); view.onResume(); Music.INSTANCE.resume(); Sample.INSTANCE.resume(); if (doOnResume != null) { Game.pushUiTask( () -> { doOnResume.run(); doOnResume = null; } ); } }
Example #2
Source File: Game.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onDestroy() { super.onDestroy(); destroyGame(); Music.INSTANCE.mute(); Sample.INSTANCE.reset(); }
Example #3
Source File: ShatteredPixelDungeon.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void create() { super.create(); updateSystemUI(); SPDAction.loadBindings(); Music.INSTANCE.enable( SPDSettings.music() ); Music.INSTANCE.volume( SPDSettings.musicVol()*SPDSettings.musicVol()/100f ); Sample.INSTANCE.enable( SPDSettings.soundFx() ); Sample.INSTANCE.volume( SPDSettings.SFXVol()*SPDSettings.SFXVol()/100f ); Sample.INSTANCE.load( Assets.Sounds.all ); }
Example #4
Source File: Game.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onPause() { super.onPause(); paused = true; view.onPause(); if (scene != null) { // view.onPause will wait for gl thread, so it safe to access scene here scene.pause(); } Music.INSTANCE.pause(); Sample.INSTANCE.pause(); Script.reset(); }
Example #5
Source File: Game.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onDestroy() { super.onDestroy(); if (scene != null) { // view.onPause will wait for gl thread, so it safe to access scene here scene.destroy(); scene = null; } Music.INSTANCE.mute(); Sample.INSTANCE.reset(); }
Example #6
Source File: Game.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public void destroy(){ if (scene != null) { scene.destroy(); scene = null; } sceneClass = null; Music.INSTANCE.stop(); Sample.INSTANCE.reset(); }
Example #7
Source File: Boss.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void setState(AiState state) { if (state instanceof Hunting) { if (battleMusic != null) { Music.INSTANCE.play(battleMusic, true); } } super.setState(state); }
Example #8
Source File: GameScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
static public void playLevelMusic() { if(Dungeon.level == null) { EventCollector.logException("attempt to play music on null level"); return; } Music.INSTANCE.play(Dungeon.level.music(), true); Music.INSTANCE.volume(1f); }
Example #9
Source File: RemixedDungeon.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EuConsent.check(this); playGames = new PlayGames(); MobileAds.initialize(this, Game.getVar(R.string.admob_app_id)); RemixedDungeon.activeMod(ModdingMode.activeMod()); if(!Utils.canUseClassicFont(uiLanguage())) { RemixedDungeon.classicFont(false); } ModdingMode.setClassicTextRenderingMode(RemixedDungeon.classicFont()); EventCollector.collectSessionData("font", String.valueOf(RemixedDungeon.classicFont())); setSelectedLanguage(); ItemSpritesDescription.readItemsDesc(); updateImmersiveMode(); DisplayMetrics metrics = new DisplayMetrics(); instance().getWindowManager().getDefaultDisplay().getMetrics(metrics); boolean landscape = metrics.widthPixels > metrics.heightPixels; if (Preferences.INSTANCE.getBoolean(Preferences.KEY_LANDSCAPE, false) != landscape) { landscape(!landscape); } Music.INSTANCE.enable(music()); Sample.INSTANCE.enable(soundFx()); }
Example #10
Source File: Game.java From PD-classes with GNU General Public License v3.0 | 5 votes |
@Override public void onResume() { super.onResume(); now = 0; view.onResume(); Music.INSTANCE.resume(); Sample.INSTANCE.resume(); }
Example #11
Source File: Game.java From PD-classes with GNU General Public License v3.0 | 5 votes |
@Override public void onPause() { super.onPause(); if (scene != null) { scene.pause(); } view.onPause(); Script.reset(); Music.INSTANCE.pause(); Sample.INSTANCE.pause(); }
Example #12
Source File: Game.java From PD-classes with GNU General Public License v3.0 | 5 votes |
@Override public void onDestroy() { super.onDestroy(); destroyGame(); Music.INSTANCE.mute(); Sample.INSTANCE.reset(); }
Example #13
Source File: Game.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onPause() { super.onPause(); if (scene != null) { scene.pause(); } view.onPause(); Script.reset(); Music.INSTANCE.pause(); Sample.INSTANCE.pause(); }
Example #14
Source File: CavesBossLevel.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void press( int cell, Char hero ) { super.press( cell, hero ); if ( progress == BOSS_ISHIDDEN && outsideEntranceRoom(cell) && hero == Dungeon.hero) { progress = BOSS_APPEARED; Mob boss = Bestiary.mob( Dungeon.depth ); boss.state = boss.HUNTING; do { boss.pos = Random.Int( LENGTH ); } while ( !passable[boss.pos] || !outsideEntranceRoom(boss.pos) || Dungeon.visible[boss.pos]); GameScene.add( boss ); set( arenaDoor, Terrain.WALL ); GameScene.updateMap( arenaDoor ); CellEmitter.get( arenaDoor ).start(Speck.factory(Speck.ROCK), 0.07f, 10 ); Camera.main.shake(3, 0.7f ); Sample.INSTANCE.play( Assets.SND_ROCKS ); Dungeon.observe(); Music.INSTANCE.play( currentTrack(), true ); } }
Example #15
Source File: Game.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void pause() { if (scene != null) { scene.onPause(); } Script.reset(); Music.INSTANCE.pause(); Sample.INSTANCE.pause(); }
Example #16
Source File: Game.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void dispose() { destroyGame(); Music.INSTANCE.mute(); Sample.INSTANCE.reset(); }
Example #17
Source File: CityBossLevel.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void press( int cell, Char hero ) { super.press(cell, hero); if ( progress == BOSS_ISHIDDEN && outsideEntranceRoom(cell) && hero == Dungeon.hero ) { progress = BOSS_APPEARED; Mob boss = Bestiary.mob( Dungeon.depth ); boss.state = boss.HUNTING; boss.pos = THRONE; ((DwarvenKing)boss).phase = true; GameScene.add( boss ); if (Dungeon.visible[boss.pos]) { boss.notice(); boss.sprite.alpha( 0 ); boss.sprite.parent.add( new AlphaTweener( boss.sprite, 1, 0.1f ) ); } set( arenaDoor, Terrain.LOCKED_DOOR ); GameScene.updateMap( arenaDoor ); Dungeon.observe(); Music.INSTANCE.play( currentTrack(), true ); } }
Example #18
Source File: Game.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void onResume() { super.onResume(); now = 0; view.onResume(); Music.INSTANCE.resume(); Sample.INSTANCE.resume(); }
Example #19
Source File: PrisonBossLevel.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void press( int cell, Char ch ) { super.press( cell, ch ); if (ch == Dungeon.hero && progress == BOSS_ISHIDDEN && roomExit.inside( cell )) { progress = BOSS_APPEARED; int pos; do { pos = roomExit.random(); } while (pos == cell || Actor.findChar( pos ) != null); Mob boss = Bestiary.mob( Dungeon.depth ); boss.state = boss.HUNTING; boss.pos = pos; GameScene.add( boss, 2f ); boss.notice(); press( pos, boss ); set( arenaDoor, Terrain.LOCKED_DOOR ); GameScene.updateMap( arenaDoor ); Dungeon.observe(); Music.INSTANCE.play( currentTrack(), true ); } }
Example #20
Source File: HallsBossLevel.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override public void press( int cell, Char hero ) { super.press( cell, hero ); if (progress == BOSS_ISHIDDEN && hero == Dungeon.hero && cell != entrance) { progress = BOSS_APPEARED; for (int i=ROOM_LEFT-1; i <= ROOM_RIGHT + 1; i++) { doMagic( (ROOM_TOP - 1) * WIDTH + i ); doMagic( (ROOM_BOTTOM + 1) * WIDTH + i ); } for (int i=ROOM_TOP; i < ROOM_BOTTOM + 1; i++) { doMagic( i * WIDTH + ROOM_LEFT - 1 ); doMagic( i * WIDTH + ROOM_RIGHT + 1 ); } doMagic( entrance ); GameScene.updateMap(); Dungeon.observe(); Yog boss = new Yog(); do { boss.pos = Random.Int( LENGTH ); } while ( !passable[boss.pos] || Dungeon.visible[boss.pos] ); GameScene.add( boss ); boss.spawnFists(); boss.yell( "Greetings, mortal. Are you ready to die?" ); stairs = entrance; entrance = -1; Music.INSTANCE.play( currentTrack(), true ); } }
Example #21
Source File: InterlevelScene.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void update() { super.update(); if(phase == Phase.ERROR) { return; } float p = timeLeft / TIME_TO_FADE; if (error != null) { add(new WndError(error) { public void onBackPressed() { super.onBackPressed(); Game.switchScene(TitleScene.class); } }); phase = Phase.ERROR; error = null; } switch (phase) { case FADE_IN: message.alpha(1 - p); if ((timeLeft -= Game.elapsed) <= 0) { if (error == null && levelChanger.isDone()) { phase = Phase.FADE_OUT; timeLeft = TIME_TO_FADE; } else { phase = Phase.STATIC; } } break; case FADE_OUT: message.alpha(p); if (mode == Mode.CONTINUE || (mode == Mode.DESCEND && Dungeon.depth == 1)) { Music.INSTANCE.volume(p); } if ((timeLeft -= Game.elapsed) <= 0) { Game.switchScene(GameScene.class); } break; case STATIC: if (levelChanger.isDone()) { phase = Phase.FADE_OUT; } break; } }
Example #22
Source File: YetAnotherPixelDungeon.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); updateImmersiveMode(); DisplayMetrics metrics = new DisplayMetrics(); instance.getWindowManager().getDefaultDisplay().getMetrics( metrics ); boolean landscape = metrics.widthPixels > metrics.heightPixels; if( Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false ) != landscape ){ landscape( !landscape ); } Badges.loadGlobal(); Music.INSTANCE.enable( music() ); Sample.INSTANCE.enable( soundFx() ); Sample.INSTANCE.load( Assets.SND_CLICK, Assets.SND_BADGE, Assets.SND_GOLD, Assets.SND_DESCEND, Assets.SND_STEP, Assets.SND_WATER, Assets.SND_OPEN, Assets.SND_UNLOCK, Assets.SND_ITEM, Assets.SND_DEWDROP, Assets.SND_HIT, Assets.SND_MISS, Assets.SND_EAT, Assets.SND_READ, Assets.SND_LULLABY, Assets.SND_DRINK, Assets.SND_SHATTER, Assets.SND_ZAP, Assets.SND_LIGHTNING, Assets.SND_LEVELUP, Assets.SND_DEATH, Assets.SND_CHALLENGE, Assets.SND_CURSED, Assets.SND_EVOKE, Assets.SND_TRAP, Assets.SND_TOMB, Assets.SND_ALERT, Assets.SND_MELD, Assets.SND_BOSS, Assets.SND_BLAST, Assets.SND_PLANT, Assets.SND_RAY, Assets.SND_BEACON, Assets.SND_TELEPORT, Assets.SND_CHARMS, Assets.SND_MASTERY, Assets.SND_PUFF, Assets.SND_ROCKS, Assets.SND_BURNING, Assets.SND_FALLING, Assets.SND_GHOST, Assets.SND_SECRET, Assets.SND_BONES, Assets.SND_BEE, Assets.SND_DEGRADE, Assets.SND_MIMIC); }
Example #23
Source File: BadgesScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); Music.INSTANCE.play( Assets.THEME, true ); uiCamera.visible = false; int w = Camera.main.width; int h = Camera.main.height; Archs archs = new Archs(); archs.setSize( w, h ); add( archs ); float left = 5; float top = 20; RenderedTextBlock title = PixelScene.renderTextBlock( Messages.get(this, "title"), 9 ); title.hardlight(Window.TITLE_COLOR); title.setPos( (w - title.width()) / 2f, (top - title.height()) / 2f ); align(title); add(title); Badges.loadGlobal(); List<Badges.Badge> badges = Badges.filtered( true ); int blankBadges = 36; blankBadges -= badges.size(); if (badges.contains(Badges.Badge.ALL_ITEMS_IDENTIFIED)) blankBadges -= 6; if (badges.contains(Badges.Badge.YASD)) blankBadges -= 5; blankBadges = Math.max(0, blankBadges); //guarantees a max of 5 rows in landscape, and 8 in portrait, assuming a max of 40 buttons int nCols = SPDSettings.landscape() ? 7 : 4; if (badges.size() + blankBadges > 32 && !SPDSettings.landscape()) nCols++; int nRows = 1 + (blankBadges + badges.size())/nCols; float badgeWidth = (w - 2*left)/nCols; float badgeHeight = (h - 2*top)/nRows; for (int i = 0; i < badges.size() + blankBadges; i++){ int row = i / nCols; int col = i % nCols; Badges.Badge b = i < badges.size() ? badges.get( i ) : null; BadgeButton button = new BadgeButton( b ); button.setPos( left + col * badgeWidth + (badgeWidth - button.width()) / 2, top + row * badgeHeight + (badgeHeight - button.height()) / 2); align(button); add( button ); } ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); add( btnExit ); fadeIn(); }
Example #24
Source File: RankingsScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); Music.INSTANCE.play( Assets.THEME, true ); uiCamera.visible = false; int w = Camera.main.width; int h = Camera.main.height; archs = new Archs(); archs.setSize( w, h ); add( archs ); Rankings.INSTANCE.load(); RenderedTextBlock title = PixelScene.renderTextBlock( Messages.get(this, "title"), 9); title.hardlight(Window.TITLE_COLOR); title.setPos( (w - title.width()) / 2f, (20 - title.height()) / 2f ); align(title); add(title); if (Rankings.INSTANCE.records.size() > 0) { //attempts to give each record as much space as possible, ideally as much space as portrait mode float rowHeight = GameMath.gate(ROW_HEIGHT_MIN, (uiCamera.height - 26)/Rankings.INSTANCE.records.size(), ROW_HEIGHT_MAX); float left = (w - Math.min( MAX_ROW_WIDTH, w )) / 2 + GAP; float top = (h - rowHeight * Rankings.INSTANCE.records.size()) / 2; int pos = 0; for (Rankings.Record rec : Rankings.INSTANCE.records) { Record row = new Record( pos, pos == Rankings.INSTANCE.lastRecord, rec ); float offset = rowHeight <= 14 ? pos %2 == 1? 5 : -5 : 0; row.setRect( left+offset, top + pos * rowHeight, w - left * 2, rowHeight ); add(row); pos++; } if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) { RenderedTextBlock label = PixelScene.renderTextBlock( 8 ); label.hardlight( 0xCCCCCC ); label.setHightlighting(true, Window.SHPX_COLOR); label.text( Messages.get(this, "total") + " _" + Rankings.INSTANCE.wonNumber + "_/" + Rankings.INSTANCE.totalNumber ); add( label ); label.setPos( (w - label.width()) / 2, h - label.height() - 2*GAP ); align(label); } } else { RenderedTextBlock noRec = PixelScene.renderTextBlock(Messages.get(this, "no_games"), 8); noRec.hardlight( 0xCCCCCC ); noRec.setPos( (w - noRec.width()) / 2, (h - noRec.height()) / 2 ); align(noRec); add(noRec); } ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); add( btnExit ); fadeIn(); }
Example #25
Source File: SPDSettings.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public static void musicVol( int value ){ Music.INSTANCE.volume(value/10f); put( KEY_MUSIC_VOL, value ); }
Example #26
Source File: BadgesScene.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); Music.INSTANCE.play( Assets.THEME, true ); Music.INSTANCE.volume( 1f ); uiCamera.setVisible(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( 160, 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 ); Text title = PixelScene.createText( Game.getVar(R.string.BadgesScene_Title), GuiProperties.titleFontSize()); title.hardlight( Window.TITLE_COLOR ); 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(); }
Example #27
Source File: SPDSettings.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public static void music( boolean value ) { Music.INSTANCE.enable( value ); put( KEY_MUSIC, value ); }
Example #28
Source File: RemixedDungeon.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
public static void music(boolean value) { Music.INSTANCE.enable(value); Preferences.INSTANCE.put(Preferences.KEY_MUSIC, value); }
Example #29
Source File: ShatteredPixelDungeon.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public void create() { super.create(); SPDSettings.fullscreen( SPDSettings.fullscreen() ); Music.INSTANCE.enable( SPDSettings.music() ); Music.INSTANCE.volume( SPDSettings.musicVol()/10f ); Sample.INSTANCE.enable( SPDSettings.soundFx() ); Sample.INSTANCE.volume( SPDSettings.SFXVol()/10f ); Sample.INSTANCE.load( Assets.SND_CLICK, Assets.SND_BADGE, Assets.SND_GOLD, Assets.SND_STEP, Assets.SND_WATER, Assets.SND_OPEN, Assets.SND_UNLOCK, Assets.SND_ITEM, Assets.SND_DEWDROP, Assets.SND_HIT, Assets.SND_MISS, Assets.SND_DESCEND, Assets.SND_EAT, Assets.SND_READ, Assets.SND_LULLABY, Assets.SND_DRINK, Assets.SND_SHATTER, Assets.SND_ZAP, Assets.SND_LIGHTNING, Assets.SND_LEVELUP, Assets.SND_DEATH, Assets.SND_CHALLENGE, Assets.SND_CURSED, Assets.SND_EVOKE, Assets.SND_TRAP, Assets.SND_TOMB, Assets.SND_ALERT, Assets.SND_MELD, Assets.SND_BOSS, Assets.SND_BLAST, Assets.SND_PLANT, Assets.SND_RAY, Assets.SND_BEACON, Assets.SND_TELEPORT, Assets.SND_CHARMS, Assets.SND_MASTERY, Assets.SND_PUFF, Assets.SND_ROCKS, Assets.SND_BURNING, Assets.SND_FALLING, Assets.SND_GHOST, Assets.SND_SECRET, Assets.SND_BONES, Assets.SND_BEE, Assets.SND_DEGRADE, Assets.SND_MIMIC ); }
Example #30
Source File: Game.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void resume() { Music.INSTANCE.resume(); Sample.INSTANCE.resume(); }