资源简介

大学杀Java版实现(仿三国杀),效果逼真!注意运行的配置,由于文件太大无法上传,故去掉了音频部分,导入可能会报错,请自行到三国杀里取相关音频文件

资源截图

代码片段和文件信息

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import sun.audio.AudioData;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import sun.audio.ContinuousAudioDataStream;

public class MusicPlay {
private AudioStream as; // 单次播放声音用
ContinuousAudioDataStream cas;// 循环播放声音

// 构造函数
public MusicPlay() {
try {
// 打开一个声音文件流作为输入
FileInputStream fileau = new FileInputStream(“music/Playing.wav“);
//as = new AudioStream(url.openStream());
 as = new AudioStream(fileau);
} catch(FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

// 一次播放 开始
public void start() {
if(as == null) {
System.out.println(“AudioStream object is not created!“);
return;
} else {
AudioPlayer.player.start(as);
}
}

// 一次播放 停止
public void stop() {
if(as == null) {
System.out.println(“AudioStream object is not created!“);
return;
} else {
AudioPlayer.player.stop(as);
}
}

// 循环播放 开始
public void continuousStart() {
// Create AudioData source.
AudioData data = null;
try {
data = as.getData();
} catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// Create ContinuousAudioDataStream.
cas = new ContinuousAudioDataStream(data);

// Play audio.
AudioPlayer.player.start(cas);
}

// 循环播放 停止
public void continuousStop() {
if(cas != null) {
AudioPlayer.player.stop(cas);
}
}
 public static void main(String[]args){
 new MusicPlay().continuousStart();
 }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-02-19 15:55  collegeKill\
     目录           0  2014-02-19 15:41  collegeKill\chinaKillerClient\
     文件         232  2011-09-27 23:40  collegeKill\chinaKillerClient\.classpath
     文件         393  2011-09-27 23:40  collegeKill\chinaKillerClient\.project
     目录           0  2014-02-19 15:41  collegeKill\chinaKillerClient\bImage\
     文件      289561  2011-09-27 23:40  collegeKill\chinaKillerClient\bImage\background.png
     文件       38676  2011-09-27 23:40  collegeKill\chinaKillerClient\bImage\textArea2.png
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\audio\
     文件        1809  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\audio\Music.class
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\message\
     文件        2502  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\message\MessagePacket.class
     文件         326  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\message\MessageType.class
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\
     文件        1276  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\GameMain$myPanel.class
     文件        1769  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\GameMain$MyTextArea.class
     文件       12295  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\GameMain.class
     文件        1505  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\Readyframe$MyButton.class
     文件        1702  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\Readyframe$MyPanel.class
     文件        2010  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\Readyframe$MyTextArea.class
     文件        8849  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userframe\Readyframe.class
     目录           0  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userThread\
     文件         445  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\userThread\UserThread.class
     文件        1003  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\CardLabel.class
     文件         391  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\CardPacket.class
     文件        4783  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\Login.class
     文件        1225  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\UserPacket.class
     文件        1538  2014-02-19 15:43  collegeKill\chinaKillerClient\bin\com\manager\user\UserPanel.class
............此处省略116个文件信息

评论

共有 条评论