1 / 40
文档名称:

俄罗斯方块游戏源代码.doc

格式:doc   大小:139KB   页数:40页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

俄罗斯方块游戏源代码.doc

上传人:乘风破浪 2019/5/6 文件大小:139 KB

下载得到文件列表

俄罗斯方块游戏源代码.doc

相关文档

文档介绍

文档介绍:JAVA游戏编程之三----j2me手机游戏入门开发--俄罗斯方块_4_增加消除行声音收藏之前的游戏代码中都未加声音,不少网友在做别业设计时要求增加声音,其实声音还是比较好做的!但手机真机上可能会有不同的问题,但在模拟器上一般都没什么问题,所以真机上的问题就具体问题具体分析吧!这里给出一个很简单的声音应用。在原俄罗斯方块_3的代码基础上增加一个声音类!示例代码如下--------------------------------------------------------------------------------viewplaincopytoclipboardprint?packagecode;.*;import;import;import;lassSound{publicstaticPlayerm_sounds;publicstaticintm_currentSoundID=-1;publicstaticbooleans_sound_bg_On=false;privatestaticfinalStringSOUND_FILENAME="/pics/";//(){if(m_sounds!=null)return;try{DataInputStreamdis=newDataInputStream("".getClass().getResourceAsStream(SOUND_FILENAME));byte[]soundBuffer=newbyte[()];(soundBuffer);InputStreamis=newByteArrayInputStream(soundBuffer);m_sounds=(is,"audio/x-wav");();();}catch(Exceptione){();}}publicstaticvoidplaySound(intsoundID){playSound(soundID,1);}publicstaticvoidplaySound(intsoundID,intloopCount){try{if(m_sounds==null)return;if(()==)return;m_currentSoundID=soundID;(0);(loopCount);();(50);//maybethiscanhelpforsoundproblems}catch(Exceptione){();}}privatestaticvoidstopSound()throwsException{try{if(m_sounds==null)return;if(()==)();if(()==)();m_currentSoundID=-1;}catch(Exceptione){();}}publicstaticintreadFileToMemory(StringfileName,byte[]buffer){file=null;intsize;try{file=().getResourceAsStream(fileName);size=(buffer);();file=null;}catch(Exceptione){return-1;}returnsize;}}packagecode;.*;import;import;import;lassSound{ publicstaticPlayer m_sounds; publicstaticint m_currentSoundID =-1; publicstaticboolean s_sound_bg_On =false; privatestaticfinalString SOUND_FILENAME ="/pics/"; // publicstaticfinalvoidinitSound() {