j2me 拼图游戏代码求解释
importjavax.microedition.lcdui.Command;importjavax.microedition.lcdui.CommandListener...
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class main extends MIDlet {
private Display display;
private Image img;
private List l;
private main m;
public main() {
display=Display.getDisplay(this);
m=this;
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
showList();
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
public void show(Displayable dis){
display.setCurrent(dis);
}
private void showList(){
List l=new List("图片",List.IMPLICIT);
l.append("1", null);
l.append("2", null);
l.append("3", null);
l.append("4", null);
l.append("5", null);
l.append("6", null);
l.append("7", null);
l.append("8", null);
l.append("9", null);
l.append("10", null);
l.append("11", null);
l.addCommand(new Command("确定",Command.OK,0));
l.addCommand(new Command("退出",Command.EXIT,1));
l.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
List temp=(List)d;
if(c.getLabel().equals("确定")){
String p_name=temp.getString(temp.getSelectedIndex());
ping mc=new ping(m,temp);
mc.addImage("/"+p_name);
mc.allimages();
mc.Rimages();
show(mc);
}
if(c.getLabel().equals("退出")){ //左软键
try {
m.destroyApp(false);
m.notifyDestroyed();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
show(l);
}
}
import javax.microedition.lcdui.Image;
public class myImage {
private Image image=null;
private int old_x=0;
private int old_y=0;
private int x=0;
private int y=0;
public myImage(Image image, int old_x, int old_y) {
super();
this.image = image;
this.old_x = old_x;
this.old_y = old_y;
this.x=old_x;
this.y=old_y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public Image getImage() {
return image;
}
public int getOld_x() {
return old_x;
}
public int getOld_y() {
return old_y;
}
public boolean check(){
if(old_x==x&&old_y==y){
return true;
}
return false;
}
}
麻烦解释的详细点,本人学cisco的缺被学校弄去搞J2ME 完全打酱油……
还有一段贴在别的地方先解释这些吧 展开
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class main extends MIDlet {
private Display display;
private Image img;
private List l;
private main m;
public main() {
display=Display.getDisplay(this);
m=this;
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
showList();
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
public void show(Displayable dis){
display.setCurrent(dis);
}
private void showList(){
List l=new List("图片",List.IMPLICIT);
l.append("1", null);
l.append("2", null);
l.append("3", null);
l.append("4", null);
l.append("5", null);
l.append("6", null);
l.append("7", null);
l.append("8", null);
l.append("9", null);
l.append("10", null);
l.append("11", null);
l.addCommand(new Command("确定",Command.OK,0));
l.addCommand(new Command("退出",Command.EXIT,1));
l.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
List temp=(List)d;
if(c.getLabel().equals("确定")){
String p_name=temp.getString(temp.getSelectedIndex());
ping mc=new ping(m,temp);
mc.addImage("/"+p_name);
mc.allimages();
mc.Rimages();
show(mc);
}
if(c.getLabel().equals("退出")){ //左软键
try {
m.destroyApp(false);
m.notifyDestroyed();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
show(l);
}
}
import javax.microedition.lcdui.Image;
public class myImage {
private Image image=null;
private int old_x=0;
private int old_y=0;
private int x=0;
private int y=0;
public myImage(Image image, int old_x, int old_y) {
super();
this.image = image;
this.old_x = old_x;
this.old_y = old_y;
this.x=old_x;
this.y=old_y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public Image getImage() {
return image;
}
public int getOld_x() {
return old_x;
}
public int getOld_y() {
return old_y;
}
public boolean check(){
if(old_x==x&&old_y==y){
return true;
}
return false;
}
}
麻烦解释的详细点,本人学cisco的缺被学校弄去搞J2ME 完全打酱油……
还有一段贴在别的地方先解释这些吧 展开
1个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询