概述
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package com.tarena.shoot;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ShootGame extends JPanel {
public static final int WIDTH=400;//固定窗口大小
public static final int HEIGHT=700;
public static BufferedImage background;//导入图片用BufferedImage
public static BufferedImage start;
public static BufferedImage airplane;
public static BufferedImage bee;
public static BufferedImage bullet;
public static BufferedImage hero1;
public static BufferedImage hero2;
public static BufferedImage pause;
public static BufferedImage gameover;
public Hero hero=new Hero();
public Flyer[] flyers={};
public Bullet[] bullets={};
private int state=START;
public static final int START=0;
public static final int RUNNING=1;
public static final int PAUSE=2;
public static final int GAME_OVER=3;
static{//静态代码块,将图片全部加载到内存方法区
try {
background=ImageIO.read(ShootGame.class.getResource("background.png"));
start=ImageIO.read(ShootGame.class.getResource("start.png"));
airplane=ImageIO.read(ShootGame.class.getResource("airplane.png"));
bee=ImageIO.read(ShootGame.class.getResource("bee.png"));
bullet=ImageIO.read(ShootGame.class.getResource("bullet.png"));
hero1=ImageIO.read(ShootGame.class.getResource("hero1.png"));
hero2=ImageIO.read(ShootGame.class.getResource("hero2.png"));
pause=ImageIO.read(ShootGame.class.getResource("pause.png"));
gameover=ImageIO.read(ShootGame.class.getResource("gameover.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
JFrame frame=new JFrame("Fly");//创建窗体对象
frame.setSize(WIDTH, HEIGHT);//设置窗体大小
frame.setAlwaysOnTop(true);//设置窗体总是在最上
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);//设置窗体出现位置居中
ShootGame game=new ShootGame();
frame.add(game);//将背景面板对象嵌入到窗体对象中
frame.setVisible(true);//自动调用paint方法
game.action();
我想在主程序中加入循环播放的bgm,求吧友帮帮忙,教教我
最后
以上就是跳跃日记本为你收集整理的java循环播放_求解答关于java小游戏怎么循环播放BGM的全部内容,希望文章能够帮你解决java循环播放_求解答关于java小游戏怎么循环播放BGM所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复