/** * Plays the current track. * * @param loop whether or not to loop the track */ public static void play(boolean loop) { if (trackExists()) { trackEnded = false; if (loop) player.loop(); else player.play(); } }
public void playTavern() { try { Random r = new Random(); active = tavern.get(r.nextInt(tavern.size())); activeCat = "tavern"; active.play(); } catch (Exception e) { // TODO: handle exception } }
public void playFight() { try { Random r = new Random(); active = fight.get(r.nextInt(fight.size())); activeCat = "fight"; active.play(); } catch (Exception e) { // TODO: handle exception } }
public void playNavTension() { try { Random r = new Random(); active = nav_tension.get(r.nextInt(nav_tension.size())); activeCat = "nav_tension"; active.play(); } catch (Exception e) { // TODO: handle exception } }
public void playNavNormal() { try { Random r = new Random(); active = nav_normal.get(r.nextInt(nav_normal.size())); activeCat = "nav_normal"; active.play(); } catch (Exception e) { // TODO: handle exception } }
/** * Plays the current track at the given position. * * @param position the track position (in ms) * @param loop whether or not to loop the track */ public static void playAt(final int position, final boolean loop) { if (trackExists()) { setVolume(Options.getMusicVolume() * Options.getMasterVolume()); trackEnded = false; pauseTime = 0f; if (loop) player.loop(); else player.play(); if (position >= 0) player.setPosition(position / 1000f); } }
/** @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { SoundStore.get().setMaxSources(32); myContainer = container; sound = new Sound("testdata/restart.ogg"); charlie = new Sound("testdata/cbrown01.wav"); engine = new Sound("testdata/engine.wav"); music = musica = new Music("testdata/SMB-X.XM"); // music = musica = new Music("testdata/theme.ogg", true); musicb = new Music("testdata/kirby.ogg", true); burp = new Sound("testdata/burp.aif"); music.play(); }
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { super.enter(container, game); keyInput = new KeyInput(); world = new World(this); world.init(); // TODO: Musicクラスの利用 music.setPosition(0); music.play(); music.loop(); // ゲーム中に動的に曲を変えたい場合 // このBasicGameStateクラスが持つクラス // 今回で言えば,Battleクラスが持つWorldクラスに, // Battleクラスの参照を渡しておき, // MusicChangeメソッドなどを作成し,呼び出させるという方法がある. // 他にも,ShootingGameクラスなどのStateBasedGameクラスに音楽管理クラスを // 持たせ,そこで管理するという方法もある. }