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

📄 nokiaeffect.java

📁 一款jbuilder开发的j2me射击游戏!
💻 JAVA
字号:
package shoot;/** * <p>Title: Shoot game from Rex</p> * <p>Description: This is a shoot game.</p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: SkyPlay</p> * @author Kevin * @version 1.0 */import com.nokia.mid.sound.Sound;import com.nokia.mid.sound.SoundListener;//import com.nokia.mid.ui.DeviceControl;public class NokiaEffect extends EffectAdapter implements SoundListener {    private volatile int state = Sound.SOUND_STOPPED;    private Sound sound = null;    private volatile int currentSoundPriority = 0;    private final static byte[] BULLET_SOUND_BYTES =    {        (byte)0x02, (byte)0x4A, (byte)0x3A, (byte)0x80,        (byte)0x40, (byte)0x21, (byte)0x33, (byte)0x0D,        (byte)0xA8, (byte)0x92, (byte)0xB0, (byte)0x23,        (byte)0x04, (byte)0x1A, (byte)0x81, (byte)0x68,        (byte)0x80, (byte)0x00    };    private final static byte[] CREATE_BULLET_SOUND_BYTES =    {        (byte)0x02, (byte)0x4A, (byte)0x3A, (byte)0x80,        (byte)0x80, (byte)0x00    };    private final static byte[] SPLASH_SOUND_BYTES =    {        (byte)0x02, (byte)0x4a, (byte)0x3a, (byte)0x40,        (byte)0x04, (byte)0x01, (byte)0x2d, (byte)0x22,        (byte)0xa2, (byte)0x71, (byte)0x21, (byte)0x44,        (byte)0x9b, (byte)0x89, (byte)0xa8, (byte)0x90,        (byte)0xa2, (byte)0x0d, (byte)0x40, (byte)0x84,        (byte)0x12, (byte)0x6a, (byte)0x04, (byte)0x20,        (byte)0x83, (byte)0x50, (byte)0x21, (byte)0x04,        (byte)0x9b, (byte)0x81, (byte)0x08, (byte)0x1a,        (byte)0x81, (byte)0x08, (byte)0x20, (byte)0xd4,        (byte)0x08, (byte)0x41, (byte)0x26, (byte)0xa0,        (byte)0x42, (byte)0x08, (byte)0x35, (byte)0x02,        (byte)0x10, (byte)0x49, (byte)0xaa, (byte)0x90,        (byte)0x61, (byte)0x08, (byte)0x10, (byte)0xa1,        (byte)0xba, (byte)0x90, (byte)0x82, (byte)0x89,        (byte)0xd4, (byte)0x84, (byte)0x12, (byte)0x6a,        (byte)0xa4, (byte)0x18, (byte)0x42, (byte)0x0a,        (byte)0x27, (byte)0x12, (byte)0x14, (byte)0x49,        (byte)0xb8, (byte)0x9a, (byte)0x8a, (byte)0x0d,        (byte)0x40, (byte)0x84, (byte)0x12, (byte)0x6a,        (byte)0x04, (byte)0x20, (byte)0x83, (byte)0x50,        (byte)0x21, (byte)0x04, (byte)0x9b, (byte)0x81,        (byte)0x08, (byte)0x28, (byte)0x9d, (byte)0x48,        (byte)0x41, (byte)0x26, (byte)0xea, (byte)0x41,        (byte)0x84, (byte)0x20, (byte)0x42, (byte)0x86,        (byte)0xa0, (byte)0x42, (byte)0x08, (byte)0x35,        (byte)0x02, (byte)0x04, (byte)0x51, (byte)0x38,        (byte)0xa4, (byte)0xdc, (byte)0x4d, (byte)0x44,        (byte)0x85, (byte)0x10, (byte)0x6a, (byte)0x04,        (byte)0x20, (byte)0x93, (byte)0x50, (byte)0x21,        (byte)0x04, (byte)0x1a, (byte)0x81, (byte)0x08,        (byte)0x24, (byte)0xdc, (byte)0x08, (byte)0x40,        (byte)0xd4, (byte)0x08, (byte)0x41, (byte)0x06,        (byte)0xa0, (byte)0x42, (byte)0x09, (byte)0x35,        (byte)0x02, (byte)0x10, (byte)0x41, (byte)0xa8,        (byte)0x10, (byte)0x82, (byte)0x4d, (byte)0x54,        (byte)0x83, (byte)0x08, (byte)0x40, (byte)0x85,        (byte)0x0d, (byte)0xc0, (byte)0x84, (byte)0x14,        (byte)0x4e, (byte)0x04, (byte)0x20, (byte)0x93,        (byte)0x55, (byte)0x20, (byte)0xc2, (byte)0x10,        (byte)0x51, (byte)0x38, (byte)0x90, (byte)0xa2,        (byte)0x4d, (byte)0xc4, (byte)0xd4, (byte)0x50,        (byte)0x6a, (byte)0x04, (byte)0x20, (byte)0x93,        (byte)0x50, (byte)0x21, (byte)0x04, (byte)0x1a,        (byte)0x81, (byte)0x08, (byte)0x24, (byte)0xdc,        (byte)0x08, (byte)0x41, (byte)0x44, (byte)0xea,        (byte)0x42, (byte)0x04, (byte)0x28, (byte)0x93,        (byte)0x75, (byte)0x20, (byte)0xc2, (byte)0x10,        (byte)0x21, (byte)0x43, (byte)0x50, (byte)0x21,        (byte)0x04, (byte)0x1a, (byte)0x80, (byte)0x00,    };    private final static byte[] BASE_EXPLODE_SOUND_BYTES =    {        (byte)0x02, (byte)0x4A, (byte)0x3A, (byte)0x80,        (byte)0x40, (byte)0x01, (byte)0x92, (byte)0x4D,        (byte)0xA8, (byte)0x82, (byte)0xD0, (byte)0x27,        (byte)0x14, (byte)0x91, (byte)0x82, (byte)0x0D,        (byte)0x41, (byte)0x27, (byte)0x20, (byte)0x00    };    private final static byte[] BLOCK_EXPLODE_SOUND_BYTES =    {        (byte)0x02, (byte)0x4A, (byte)0x3A, (byte)0x80,        (byte)0x40, (byte)0x01, (byte)0x12, (byte)0xCC,        (byte)0xA8, (byte)0x83, (byte)0x10, (byte)0x39,        (byte)0x02, (byte)0x31, (byte)0x2B, (byte)0x00,        (byte)0x00    };    public void soundStateChanged(Sound s, int event)    {        if ((s == sound) && (event == Sound.SOUND_STOPPED))        {            setState(Sound.SOUND_STOPPED);            currentSoundPriority = 0;        }    }    private synchronized void setState(int state)    {        this.state = state;    }    private void playSound(int priority, byte[] bytes)    {        if ((priority > currentSoundPriority))        {            try            {                if (sound == null)                {                    sound = new Sound(bytes, Sound.FORMAT_TONE);                    sound.setSoundListener(this);                }                if (state == Sound.SOUND_PLAYING)                {                    sound.stop();                }                sound.init(bytes, Sound.FORMAT_TONE);                sound.play(1); // loop = 1                // Set state and priority after play,                // in case an exception is thrown.                setState(Sound.SOUND_PLAYING);                currentSoundPriority = priority;            }            catch(Exception e)            {                // This is bullet-proofing (e.g. IllegalStateException).                setState(Sound.SOUND_STOPPED);                currentSoundPriority = 0;            }        }    }    public void playSound(int cyc){        switch(cyc){            case 0:                playSound(100,SPLASH_SOUND_BYTES);                break;            case 1:                playSound(2, BULLET_SOUND_BYTES);                break;            case 2:                playSound(1, BASE_EXPLODE_SOUND_BYTES);                break;            case 3:                playSound(3, BLOCK_EXPLODE_SOUND_BYTES);                break;            case 4:                playSound(4, CREATE_BULLET_SOUND_BYTES);                break;            default:                break;        }    }    public void stopSound(){        if (sound != null)        {            sound.stop();        }        //DeviceControl.stopVibra();    }    void vibrate()    {        try        {            // Vibrate at 100% for 200 msec.            //DeviceControl.startVibra(100, 200);        }        catch(Exception e)        {            // An IllegalStateException is thrown if the device doesn't            // have vibration support. We can't do anything, so just ignore it.        }    }}

⌨️ 快捷键说明

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