gamemenu.java
来自「用J2ME实现的战棋类小游戏DEMO,寻路用A星算法,因为时间关系物品使用功能请」· Java 代码 · 共 74 行
JAVA
74 行
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import midp20.GameTools;
public class GameMenu {
Image[] pic;
Image img_res;
Image imgtitle;
private int times = 0;
public static final int GAMESTART = 0;
public static final int GAMECONTINUE = 1;
public static final int GAMEOPTION = 2;
public static final int GAMEHELP = 3;
public static final int GAMEABOUT = 4;
public static final int GAMEEXIT = 5;
private int menuIndex = 0;
public GameMenu() {
pic = new Image[7];
Graphics bg;
img_res = GameTools.createImg("/title.png");
imgtitle=GameTools.createImg("/start.png");
for (int i = 0; i < 7; i++) {
pic[i] = Image.createImage(53, 13);
bg = pic[i].getGraphics();
bg.drawImage(img_res, 0, 0 - 13 * i, 0);
}
}
public int getMenuIndex() {
return menuIndex;
}
public void menuLeft() {
times++;
if (times != 3)
return;
times = 0;
if (menuIndex > 0)
menuIndex--;
else
menuIndex = 6;
}
public void menuRight() {
times++;
if (times != 3)
return;
times = 0;
if (menuIndex < 6)
menuIndex++;
else
menuIndex = 0;
}
public void renderMenu(Graphics g) {
g.drawImage(imgtitle, 0, -15, 0);
g.drawImage(pic[menuIndex], 65, 150, 0);
// g.setClip(100, 200, 53, 13);
// g.drawImage(img_res, 100, 200 - 13 * menuIndex, 0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?