拼图的方格类,代码:
package cn.edu.xtu.tilepuzzle.model;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class ClassPiece {
Image img;
boolean addString=false;//是否在每个方格上添加图片的原始位置
int cellWidth;//方格的宽
int cellHeight;//方格的高
int serial; // serial number for ordering
//方格的初始化位置
int ix; // initial location in grid coordinates
int iy; // initial location in grid coordinates
//方格的当前位置
public int x; // current location in grid coordinates
public int y; // current location in grid coordinates
ClassPiece(Image img_,int ser, int nx, int ny,int cellWidth,int cellHeight) {
img=img_;
serial = ser;
x = ix = nx;
y = iy = ny;
this.cellHeight=cellHeight;
this.cellWidth=cellWidth;
}
void setImg(Image img_){
img=img_;
}
void setLocation(int nx, int ny) {
this.x = nx;
this.y = ny;
}
// assumes background is white
public void paint(Graphics g) {
int px = y * cellWidth; //行坐标
int py = x * cellHeight; //列坐标
g.drawImage(img, px, py, Graphics.LEFT | Graphics.TOP);
if(addString){
String str=(1+this.ix)+" , "+(1+this.iy);
g.setColor(100, 100, 245);
g.setFont(Font.getDefaultFont());
g.drawString(str, px+(img.getWidth() - Font.getDefaultFont().stringWidth(str)) / 2,py+(img.getHeight()-Font.getDefaultFont().getHeight())/2, Graphics.LEFT | Graphics.TOP);
}
}
boolean isHome() {
return (x == ix) && (y == iy);
}
public void goHome() {
this.x=ix;
this.y=iy;
}
public int getCellWidth() {
return cellWidth;
}
public void setCellWidth(int cellWidth) {
this.cellWidth = cellWidth;
}
public int getCellHeight() {
return cellHeight;
}
public void setCellHeight(int cellHeight) {
this.cellHeight = cellHeight;
}
}
个人信息类,代码:
package cn.edu.xtu.tilepuzzle.model;
import javax.microedition.lcdui.Image;
public class ClassPeopleInfo {
/**
name;flag;time
*/
public String name="";
public String flag="3x4";// 表示 是 3列4行 4x5
public long time=0;
public String strTime="";
public Image showImage;
public Image getShowImage() {
return showImage;
}
public void setShowImage(Image showImage) {
this.showImage = showImage;
}
public ClassPeopleInfo(){
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
//System.out.println("设置类型:"+flag);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
//System.out.println("设置名字:"+name);
}
public long getTime() {
return time;
}
public void setTime(long time) {
//System.out.println("设置时间:"+time);
this.time = time;
String space="";
if(time>=1000&&time<10000)space="";
else if(time>=100)space=" ";
else if(time>=10)space=" ";
else {
space=" ";
}
this.strTime=String.valueOf(time)+space+"秒";//BoardModel.getTimeString(time);
}
public String getStrTime() {
return strTime;
}
}
选择背景拼图的列表类,代码:
package cn.edu.xtu.tilepuzzle.model;
import cn.edu.xtu.tilepuzzle.GameDB;
public class ClassListItem {
public String imageDefalut_1 = GameDB.imageDefalut_1Path;
public String imageDefalut_2 = GameDB.imageDefalut_2Path;
/**
* 原图地址
* */
public String photoString="";
public String getPhotoString() {
return photoString;
}
public void setPhotoString(String photoString) {
this.photoString = photoString;
}
/**
* 预览图地址
* */
public String iconString="";
/**
* 默认图片
*/
private String defaultImagePath = "";
/**
* 组
*/
public static int GROUP = 1;
/**
* 记录
*/
public static int ITEM = 0;
/**
* 是否选中
*/
private boolean ifselected = false;
/**
* 显示Label
*/
private String label;
/**
* 类型:组,记录
*/
/**
* 存储的对象
*/
private Object content;
public int indexInItemList=0;
public int getIndexInItemList() {
return indexInItemList;
}
public void setIndexInItemList(int indexInItemList) {
this.indexInItemList = indexInItemList;
}
private int type;
public ClassListItem(Object content,String photoString,String iconString, String Label, int type,boolean isSelect,int indexInItemList) {
this.iconString = iconString;
this.photoString=photoString;
//System.out.println("22222222");
//System.out.println(iconString);
this.label = Label;
this.type = type;
this.content=content;
this.indexInItemList=indexInItemList;
this.setIfselected(isSelect);
}
public void setIconString(String iconString) {
this.iconString=iconString;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public boolean Ifselected() {
return ifselected;
}
public void setIfselected(boolean ifselected) {
this.ifselected = ifselected;
if (this.type == ClassListItem.GROUP) {
if (!ifselected)
this.defaultImagePath = imageDefalut_1;
else
this.defaultImagePath = imageDefalut_2;
}else
System.out.println(iconString);;
}
public String toString() {
return this.label + " ";
}
public String getDefaultImagePath() {
return defaultImagePath;
}
public void setDefaultImagePath(int flag) {
if (flag == 1)
this.defaultImagePath = imageDefalut_1;
else if (flag == 2)
this.defaultImagePath = imageDefalut_2;
else
;
}
public Object getContent() {
return content;
}
public void setContent(Object content) {
this.content = content;
}
}
分享到:
相关推荐
j2me Picpuzzle 拼图游戏 可选择自己喜欢的背景图片 操作简单
本游戏实现了拼图游戏的基本功能,另外有计时,计步,暂停,重新开始,RMS持久存储,支持图像的动态切分。。。。。
J2ME 拼图游戏源码 J2ME 拼图游戏源码 J2ME 拼图游戏源码
实现了J2me拼图小游戏,可以选择图片,难度,分别有3x3,4x4,5x5,游戏中进行了计时,计步数。根据时间,步数进行评分,给出最后得分并根据不同等级显示不同的图片
java毕业设计——java基于J2ME的手机游戏开发设计与实现(论文+源代码).zip java毕业设计——java基于J2ME的手机游戏开发设计与实现(论文+源代码).zip java毕业设计——java基于J2ME的手机游戏开发设计与实现(论文+源...
j2me拼图游戏+游戏动画.。
J2ME游戏开发 J2ME游戏开发 J2ME游戏开发
Java写的j2me拼图游戏源码,代码中的注释非常多,学习来说比较有用,两种方法编辑本拼图游戏源代码: 用eclipse打开:在eclipse左侧包资源管理器中右键选择导入,然后选择现有项目到工作空间中,点下一步,在选择...
J2ME开发 J2ME开发 J2ME开发 J2ME开发
这个程序是基于J2ME的简单拼图,有三个管卡可以选择。包内不仅有项目还有实验报告,比较清楚的介绍了我的这个实验项目
j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解j2ME游戏开发详解
j2me拼图游戏,利用面向对象实现。是中国移动mm培训讲师讲的一个项目
JAVA基于J2ME的手机游戏开发(论文+源代码)JAVA基于J2ME的手机游戏开发(论文+源代码)JAVA基于J2ME的手机游戏开发(论文+源代码)JAVA基于J2ME的手机游戏开发(论文+源代码)JAVA基于J2ME的手机游戏开发(论文+源代码)JAVA...
j2me游戏开发j2me游戏开发j2me游戏开发j2me游戏开发j2me游戏开发j2me游戏开发j2me游戏开发
JAVA基于J2ME的手机游戏开发(LW+源代码)JAVA基于J2ME的手机游戏开发(LW+源代码)JAVA基于J2ME的手机游戏开发(LW+源代码)JAVA基于J2ME的手机游戏开发(LW+源代码)JAVA基于J2ME的手机游戏开发(LW+源代码)JAVA基于J2ME的...
JAVA基于J2ME的手机游戏开发(论文+源代码) JAVA基于J2ME的手机游戏开发(论文+源代码) JAVA基于J2ME的手机游戏开发(论文+源代码) JAVA基于J2ME的手机游戏开发(论文+源代码) JAVA基于J2ME的手机游戏开发(论文+源代码) ...
JAVA基于J2ME的手机游戏开发(lw+源代码).rarJAVA基于J2ME的手机游戏开发(lw+源代码).rarJAVA基于J2ME的手机游戏开发(lw+源代码).rarJAVA基于J2ME的手机游戏开发(lw+源代码).rarJAVA基于J2ME的手机游戏开发(lw+源代码...
很简单的j2me拼图游戏用canvas做的
j2me手机游戏开发j2me手机游戏开发技术详解