⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bomberbgm.java

📁 经典游戏炸弹人游戏
💻 JAVA
字号:
import java.io.*;

/**
 * File:         BomberBGM
 * Copyright:    Copyright (c) 2001
 * @author Sammy Leong
 * @version 1.0
 */

/**
 * This class plays the background music.
 */
public class BomberBGM {

    /** SoundPlayer object */
    private static Object player;
    /** last music played */
    private static int lastSelection = -1;

    static {
        /** if Java2 available */
        if (Main.J2) {
           /** create the SoundPlayer object and load the music files */
           try {
               player = new SoundPlayer(
           new File(BomberMain.RP + "Sounds/BomberBGM/").
           getCanonicalPath());
           }
           catch (Exception e) { new ErrorDialog(e); }
           ((SoundPlayer)player).open();
        }
    }

    /**
     * Change BGM music.
     * @param arg BGM music to chagne to
     */
    public static void change(String arg) {
        /** if Java 2 available */
        if (Main.J2) {
            /**
             * change music only if the the current music is not equal to
             * the specified music
             */
            int i = 0;
            while (i < ((SoundPlayer)player).sounds.size() &&
            ((SoundPlayer)player).sounds.elementAt(i).
            toString().indexOf(arg) < 0) i += 1;
            if (i != lastSelection && i <
               ((SoundPlayer)player).sounds.size()) {
                lastSelection = i;
                ((SoundPlayer)player).change(lastSelection, true);
            }
        }
    }

    /**
     * Stop playing the BGM.
     */
    public static void stop()
    {
        /** if Java 2 available */
        if (Main.J2) {
           ((SoundPlayer)player).controlStop();
        }
    }

    /**
     * Mute the BGM.
     */
    public static void mute()
    {
        /** if Java 2 available */
        if (Main.J2) {
           ((SoundPlayer)player).mute();
        }
    }

    /**
     * Unmute the BGM.
     */
    public static void unmute()
    {
        /** if Java 2 available */
        if (Main.J2) {
            ((SoundPlayer)player).unmute();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -