小编use*_*603的帖子

Java Sound播放一次,然后再播放

我有一个需要能够播放声音的游戏.当我点击一个按钮时,声音会播放,但是当我再次点击该按钮时,声音就不会播放.

下面是我的声音类:

public class Sound {

  public static final Sound select = new Sound("/selectBTN.wav");
  public static final Sound scroll = new Sound("/btn.wav");

  //Phone calls
  public static final Sound call1 = new Sound("/calls/call1.wav");
  public static final Sound call2 = new Sound("/calls/call2.wav");
  public static final Sound call3 = new Sound("/calls/call3.wav");


  private Clip c;

  public Sound(final String filename) {
    try {
         c = AudioSystem.getClip();
         final AudioInputStream inputStream AudioSystem.getAudioInputStream(Sound.class.getResourceAsStream(filename));
         c.open(inputStream);
         c.addLineListener(new LineListener() {

           @Override
           public void update(final LineEvent event) {
              if (event.getType().equals(Type.STOP)) {
                   System.out.println("Do …
Run Code Online (Sandbox Code Playgroud)

java audio

2
推荐指数
1
解决办法
491
查看次数

Java将字符串格式化为小数位

我喜欢游戏的军事和有那个报时顶部的一栏(例如),当它在它说4日上午4:06:6是有办法,我可以改变说04:06,但也说(例子)11:45而不是011:045.

这是时间等级:

public class Hud {

    public int x, y;
    public int money = 1000;
    public int reputation = 5;
    public int wifi = 3;

    public int time = 0;
    public int timer = 10;
    public int minute = 50;
    public int hour = 10;

    public Hud(int x, int y) {
        this.x = x;
        this.y = y;

    }

    public void tick() {
        if (time >= timer) {
            time = 0;
            minute++;
        } else if (time <= timer) {
            time++;
        } …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
46
查看次数

标签 统计

java ×2

audio ×1