俄羅斯方塊游戲源代碼4

俄羅斯方塊游戲源代碼4

ID:9368332

大?。?85.00 KB

頁數(shù):39頁

時間:2018-04-29

俄羅斯方塊游戲源代碼4_第1頁
俄羅斯方塊游戲源代碼4_第2頁
俄羅斯方塊游戲源代碼4_第3頁
俄羅斯方塊游戲源代碼4_第4頁
俄羅斯方塊游戲源代碼4_第5頁
資源描述:

《俄羅斯方塊游戲源代碼4》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。

1、俄羅斯方塊游戲源代碼4.txt女人謹記:一定要吃好玩好睡好喝好。一旦累死了,就別的女人花咱的錢,住咱的房,睡咱的老公,泡咱的男朋友,還打咱的娃。JAVA游戲編程之三----j2me手機游戲入門開發(fā)--俄羅斯方塊_4_增加消除行聲音收藏之前的游戲代碼中都未加聲音,不少網(wǎng)友在做別業(yè)設(shè)計時要求增加聲音,其實聲音還是比較好做的!但手機真機上可能會有不同的問題,但在模擬器上一般都沒什么問題,所以真機上的問題就具體問題具體分析吧!這里給出一個很簡單的聲音應(yīng)用。在原俄羅斯方塊_3的代碼基礎(chǔ)上增加一個聲音類!示例代碼如下--

2、------------------------------------------------------------------------------viewplaincopytoclipboardprint?packagecode;importjava.io.*;importjavax.microedition.media.Manager;importjavax.microedition.media.MediaException;importjavax.microedition.media.Playe

3、r;publicclassSound{publicstaticPlayerm_sounds;publicstaticintm_currentSoundID=-1;publicstaticbooleans_sound_bg_On=false;privatestaticfinalStringSOUND_FILENAME="/pics/newmsg.wav";//0.背景聲音publicstaticfinalvoidinitSound(){if(m_sounds!=null)return;try{DataInput

4、Streamdis=newDataInputStream("".getClass().getResourceAsStream(SOUND_FILENAME));byte[]soundBuffer=newbyte[dis.available()];dis.read(soundBuffer);InputStreamis=newByteArrayInputStream(soundBuffer);m_sounds=Manager.createPlayer(is,"audio/x-wav");m_sounds.real

5、ize();m_sounds.prefetch();}catch(Exceptione){e.printStackTrace();}}publicstaticvoidplaySound(intsoundID){playSound(soundID,1);}publicstaticvoidplaySound(intsoundID,intloopCount){try{if(m_sounds==null)return;if(m_sounds.getState()==javax.microedition.media.P

6、layer.STARTED)return;m_currentSoundID=soundID;m_sounds.setMediaTime(0);m_sounds.setLoopCount(loopCount);m_sounds.start();Thread.sleep(50);//maybethiscanhelpforsoundproblems}catch(Exceptione){e.printStackTrace();}}privatestaticvoidstopSound()throwsException{

7、try{if(m_sounds==null)return;if(m_sounds.getState()==javax.microedition.media.Player.STARTED)m_sounds.stop();if(m_sounds.getState()==javax.microedition.media.Player.PREFETCHED)m_sounds.deallocate();m_currentSoundID=-1;}catch(Exceptione){e.printStackTrace();

8、}}publicstaticintreadFileToMemory(StringfileName,byte[]buffer){java.io.InputStreamfile=null;intsize;try{file=fileName.getClass().getResourceAsStream(fileName);size=file.read(buffer);file.close();file=n

當前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動畫的文件,查看預(yù)覽時可能會顯示錯亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時聯(lián)系客服。
3. 下載前請仔細閱讀文檔內(nèi)容,確認文檔內(nèi)容符合您的需求后進行下載,若出現(xiàn)內(nèi)容與標題不符可向本站投訴處理。
4. 下載文檔時可能由于網(wǎng)絡(luò)波動等原因無法下載或下載錯誤,付費完成后未能成功下載的用戶請聯(lián)系客服處理。