📄 gamemenu.java
字号:
}
// 画出选择菜单
public void drawMenuSelect(Graphics graphics, int selectCount,
int menuMoveDistance, int menu2MoveDistance, int lightChangeTimes,
int anchor) {
this.drawMenuEffect(graphics, menuMoveDistance, menu2MoveDistance,
lightChangeTimes, anchor);
graphics.setClip(0, 0, GameConstant.iSCREEN_WIDTH,
GameConstant.iSCREEN_HEIGHT);
graphics.drawImage(menu_back, GameConstant.MENU_BACK_XPOS,
GameConstant.MENU_BACK_YPOS, anchor);
graphics.setClip(0, 0, GameConstant.iSCREEN_WIDTH,
GameConstant.iSCREEN_HEIGHT);
graphics.drawImage(menu[selectCount], GameConstant.iSCREEN_WIDTH >> 1,
GameConstant.MENU_WORD_YPOS, GameConstant.CENTER);
graphics.setClip(0, 0, GameConstant.iSCREEN_WIDTH,
GameConstant.iSCREEN_HEIGHT);
graphics.drawImage(menu_next, GameConstant.MENU_NEXT_XPOS,
GameConstant.MENU_NEXT_YPOS, anchor);
graphics.drawImage(imageSoftstar, GameConstant.MENU_SOFTSTAR_XPOS,
GameConstant.MENU_SOFTSTAR_YPOS, anchor);
}
/*
* xPos 图片的X坐标 yPos 图片的Y坐标 menuMoveDistance 菜单的移动距离 menu2MoveDistance
* 第二个菜单移动的距离
*/
public void drawMenuEffect(Graphics graphics, int menuMoveDistance,
int menu2MoveDistance, int lightChangeTimes, int anchor) {
graphics.drawImage(imageTitle, 0, 0, anchor);
graphics.drawImage(menu_show[2], GameConstant.MENU2_XPOS,
GameConstant.MENU2_YPOS + menu2MoveDistance - 10, anchor);
graphics.drawImage(menu_show[0], GameConstant.MENU0_XPOS
+ menuMoveDistance, GameConstant.MENU0_YPOS, anchor);
graphics.drawImage(menu_show[1], GameConstant.MENU1_XPOS
- (menuMoveDistance + 25), GameConstant.MENU1_YPOS, anchor);
graphics.drawImage(menu_show[3], GameConstant.MENU3_XPOS
+ (menuMoveDistance - 10), GameConstant.MENU3_YPOS, anchor);
graphics.drawImage(menu_show[4], GameConstant.MENU4_XPOS
- (menuMoveDistance + 10), GameConstant.MENU4_YPOS, anchor);
}
// 画出选择主角飞机菜单
public void drawMenuSelectPlane(Graphics graphics, int planeType) {
graphics.drawImage(imagePlane[0], 0, 0, GameConstant.TOPLEFT);
graphics.drawImage(imagePlane[planeType], 72, 90, GameConstant.CENTER);
if (planeType == 1) {
graphics.drawImage(imagePlane[3], 132, 44, GameConstant.TOPLEFT);
graphics.setColor(0, 55, 175);
graphics.fillRect(60, 155, 60, 8);
graphics.setColor(255, 0, 0);
graphics.fillRect(60, 177, 80, 8);
} else if (planeType == 2) {
graphics.drawImage(imagePlane[3], 132, 95, GameConstant.TOPLEFT);
graphics.setColor(0, 55, 175);
graphics.fillRect(60, 155, 70, 8);
graphics.setColor(255, 0, 0);
graphics.fillRect(60, 177, 60, 8);
}
}
//画帮助菜单
public void drawMenuHelp(Graphics graphics, byte index) {
Tool.fillScreen(graphics, 0x000000); // 设置黑屏
// graphics.setColor(0xFFFFFF); // 设置字体颜色
// System.out.println("2424244");
// 显示游戏帮助字体
// graphics.drawString("游戏帮助", GameConstant.iSCREEN_WIDTH / 2 - 20, 0,
// GameConstant.TOPLEFT);
// System.out.println("43543553");
// System.out.println("index====" + index);
// int row = 0;
// for (byte i = index; i < (index + 9); i++) {
// //System.out.println("" + (String) menuHelp.elementAt(i));
//
// graphics.drawString((String) menuHelp.elementAt(i), 5,
// GameConstant.iSCREEN_HEIGHT * (1 + row++) / 10,
// GameConstant.TOPLEFT);
// }
graphics.drawImage(helpImage[index], GameConstant.iSCREEN_WIDTH >> 1,
GameConstant.iSCREEN_HEIGHT >> 1, GameConstant.CENTER);
}
// 画出选择武器菜单
public void drawMenuSelectWeapon(Graphics graphics, byte[] weaponType) {
graphics.drawImage(imageWeapon[0], 0, 0, GameConstant.TOPLEFT);
graphics.drawImage(imageWeapon[weaponType[0]],
GameConstant.iSCREEN_WIDTH >> 2,
GameConstant.iSCREEN_HEIGHT >> 2, GameConstant.CENTER);
drawWeaponDescription(graphics, weaponType[0], 23, 3);
graphics.drawImage(imageWeapon[weaponType[1]],
GameConstant.iSCREEN_WIDTH - (GameConstant.iSCREEN_WIDTH >> 2),
GameConstant.iSCREEN_HEIGHT >> 2, GameConstant.CENTER);
drawWeaponDescription(graphics, weaponType[1], 111, 3);
graphics.drawImage(imageWeapon[weaponType[2]],
GameConstant.iSCREEN_WIDTH >> 2, GameConstant.iSCREEN_HEIGHT
- (GameConstant.iSCREEN_HEIGHT >> 2),
GameConstant.CENTER);
drawWeaponDescription(graphics, weaponType[2], 23, 191);
graphics.drawImage(imageWeapon[weaponType[3]],
GameConstant.iSCREEN_WIDTH - (GameConstant.iSCREEN_WIDTH >> 2),
GameConstant.iSCREEN_HEIGHT
- (GameConstant.iSCREEN_HEIGHT >> 2),
GameConstant.CENTER);
drawWeaponDescription(graphics, weaponType[3], 111, 191);
}
private void drawWeaponDescription(Graphics graphics, byte weaponType,
int screenXpos, int screenYpos) {
graphics.setFont(smallFont);
graphics.setColor(0, 212, 255);
switch (weaponType) {
case 1:
graphics.drawString(GameConstant.STR_WEAPON_BIGMISSILE, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
case 2:
graphics.drawString(GameConstant.STR_WEAPON_MACHINEGUN, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
case 3:
graphics.drawString(GameConstant.STR_WEAPON_ROCKET, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
case 4:
graphics.drawString(GameConstant.STR_WEAPON_SPEED, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
case 5:
graphics.drawString(GameConstant.STR_WEAPON_WING, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
case 6:
graphics.drawString(GameConstant.STR_WEAPON_BOMB, screenXpos,
screenYpos, GameConstant.TOPLEFT);
break;
}
}
//画排行榜菜单
public void drawMenuScore(Graphics graphics, int score, byte [] engNum,byte egNumIdx) {
graphics.drawImage(backGroundImage, 0, 0, GameConstant.TOPLEFT);
graphics.drawImage(scoreWord, 57, 13, GameConstant.TOPLEFT);
for (int idx = 0; idx < egNumIdx + 1; idx++) {
if (idx == egNumIdx) {
english[engNum[egNumIdx] % 26].drawGetClipImage(graphics, 25 + idx*9,
44, GameConstant.TOPLEFT);
} else {
english[engNum[idx] % 26].drawGetClipImage(graphics, 25 + idx* 9, 44,
GameConstant.TOPLEFT);
}
}
drawScore(graphics,score,0);
graphics.setColor(0, 212, 255);
graphics.drawString(GameConstant.STR_SCORE_OVER, 16, 188,
GameConstant.TOPLEFT);
}
public void showScore(Graphics graphics, byte[][] egNums,
String[] playerScore) {
graphics.drawImage(backGroundImage, 0, 0, GameConstant.TOPLEFT);
graphics.drawImage(scoreWord, 57, 13, GameConstant.TOPLEFT);
for (int i = 0; i < egNums.length; i++) {
for(int j=0;j<egNums[i].length;j++){
english[egNums[i][j] % 26].drawGetClipImage(graphics, 25 + j*9,
44 + i* 18, GameConstant.TOPLEFT);
}
int score = Integer.parseInt(playerScore[i]);
drawScore(graphics,score,i);
}
}
public void drawScore(Graphics graphics,int score,int rows){
for (int i = 0; i < whatIsNum("" + score); i++) {
scoreNum[(score % (Tool.square(i) * 10)) / Tool.square(i)]
.drawGetClipImage(graphics, GameConstant.iSCREEN_WIDTH - (35
+ i * 9), 44 + rows * 18, GameConstant.TOPLEFT);
}
}
public void releaseLogoObject() {
logo1 = null;
logo2 = null;
imageConfirm = null;
imageBack = null;
}
// 画出特殊的字体效果
public void drawWordsEffect(Graphics graphics, String strWords, int posX,
int posY, int frontColor, int backColor, Font font) {
graphics.setFont(font);
graphics.setColor(backColor);
graphics.drawString(strWords, posX, posY, GameConstant.TOPLEFT);
graphics.setColor(frontColor);
graphics.drawString(strWords, posX + 1, posY + 1, GameConstant.TOPLEFT);
}
// 画游戏子菜单
public void drawGameMenu(Graphics graphics, int selIdx) {
graphics.drawImage(backGroundImage, 0, 0, GameConstant.TOPLEFT);
graphics.drawImage(gameMenuWord, 47, 47, GameConstant.TOPLEFT);
graphics.drawImage(gameMenuSec, 45, 45 + selIdx * 28, GameConstant.TOPLEFT);
}
// 画设置菜单
public void drawSetMenu(Graphics graphics, byte setCount) {
Tool.fillScreen(graphics, 0);
graphics.drawImage(menu_Music, (GameConstant.iSCREEN_WIDTH >> 1)
- (menu_Music.getWidth() >> 1), 40, GameConstant.TOPLEFT);
if (setCount == 0) {
graphics.drawImage(menu_next, (GameConstant.iSCREEN_WIDTH >> 1)
- (menu_Music.getWidth() >> 1) - music_On.getWidth() - 15,
62, GameConstant.TOPLEFT);
} else if (setCount == 1) {
graphics.drawImage(menu_next, (GameConstant.iSCREEN_WIDTH >> 1)
+ (menu_Music.getWidth() >> 1) - 15, 62,
GameConstant.TOPLEFT);
}
graphics.drawImage(music_On, (GameConstant.iSCREEN_WIDTH >> 1)
- (menu_Music.getWidth() >> 1) - music_On.getWidth(), 60,
GameConstant.TOPLEFT);
graphics.drawImage(music_Off, (GameConstant.iSCREEN_WIDTH >> 1)
+ (menu_Music.getWidth() >> 1), 60, GameConstant.TOPLEFT);
}
//判断数字是多少位
private int whatIsNum(String score){
return score.length();
}
private static GameMenu gameMenu = new GameMenu();
// 初始LOGO图片
private Image logo1;
private Image logo2;
// 初始选择声音图片
private Image imageConfirm;
private Image imageBack;
// 菜单图片
private Image[] menu_show = null;
private Image[] menu = null;
private Image menu_back;
private Image menu_next;
// 选择飞机菜单图片
private Image[] imagePlane = null;
// 选择飞机武器图片
private Image[] imageWeapon = null;
// 菜单背景图片
private Image imageTitle;
private Image imageSoftstar;
// 菜单分数排行榜图片
private Image backGroundImage = null;
private Image scoreWord = null;
private CImage [] scoreNum = null;
private CImage [] english = null;
// 设置子菜单
private Image menu_Music = null;
private Image music_On = null;
private Image music_Off = null;
// 菜单帮助
//private Vector menuHelp = null;
private Font smallFont = Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD,Font.SIZE_SMALL);
private Image [] helpImage;
// 子菜单
private Image gameMenuWord = null;
private Image gameMenuSec = null;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -