下载此文档

java推箱子游戏源代码.doc


文档分类:IT计算机 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍
import ;
import ;
import ;
import ;
import ;
import ;
public class GameFrame extends JFrame {

JPanel zhuobu = new JPanel();
//工人
JLabel worker = null;
//箱子
JLabel box = null;
//目的地
JLabel goal = null;
JLabel[] walls = null;

//设置图片大小
int imgSize = 48;

public void setImgSize(int imgSize){
= imgSize;
}

public GameFrame(String title) throws HeadlessException {
super(title);
//构造方法中调用本类的其它方法
();


}

/**
* 设置内容面板
*/
void initContentPane() {
();
(null);
//调用父类的属性和方法
(zhuobu);

}

/**
* 把某个图片以组件的方式加入窗体
* ***@param imgPath 图片路径
* ***@param x x
* ***@param y y
* ***@param width 宽度
* ***@param height 高度
* ***@return 添加完的组件
*/
void ponent(int tag, String imgPath, int x, int y) {
ImageIcon img = new ImageIcon(imgPath);
//创建JLabel并把ImageIcon通过构造方法传参传入
//把食物放到盘子里
= new JLabel(img);
//设置盘子在桌布上的位置和大小
.setBounds(x, y, imgSize, imgSize);
//把盘子放到桌布上
zhuobu.);
switch (tag) {
case 1:
box = ;
break;
case 2:
goal = ;
break;
case 3:
worker = ;
break;
}

}

void addWall(String imgPath, int[][] loactions) {
ImageIcon wallImg = new ImageIcon(imgPath);
walls = ne

java推箱子游戏源代码 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人bdjigr52
  • 文件大小25 KB
  • 时间2018-07-31