📄 gamescreen.java
字号:
package com.centerscore.game;
import javax.microedition.lcdui.*;
class GameScreen extends Canvas {
static final byte MENU_RESUME = 0;
static final byte MENU_HELP = 1;
static final byte MENU_SAVEQUIT = 2;
static boolean g_bdrawSaving;
static boolean g_bdrawLoading;
int m_selectedIndex;
private GameModel m_pGameModel;
private GameMidlet m_pGameMidlet;
GameScreen(GameMidlet midlet) {
m_pGameMidlet = midlet;
setCommandListener(m_pGameMidlet);
m_selectedIndex = Globals.MAIN_SELECT_START;
addCommand(m_pGameMidlet.m_cmdBack);
}
void setModel(GameModel pModel) {
m_pGameModel = pModel;
}
protected void paint(Graphics g) {
if (g_bdrawSaving) {
m_pGameModel.drawSavingScreen(g);
} else if (g_bdrawLoading) {
m_pGameModel.drawLoadingScreen(g);
} else {
m_pGameModel.drawSelf(g);
}
}
protected void keyReleased(int key) {
int action = getGameAction(key);
if (!m_pGameModel.g_bPaused) {
m_pGameModel.handleKeyRelease(key);
}
}
protected void keyPressed(int key) {
if (!m_pGameModel.g_bPaused) {
m_pGameModel.handleKeyPress(key);
} else {
switch (getGameAction(key)) {
case Canvas.UP :
if (m_selectedIndex > MENU_RESUME) {
m_selectedIndex--;
} else {
m_selectedIndex = MENU_SAVEQUIT;
}
repaint();
break;
case Canvas.DOWN :
if (m_selectedIndex < MENU_SAVEQUIT) {
m_selectedIndex++;
} else {
m_selectedIndex = MENU_RESUME;
}
repaint();
break;
case Canvas.FIRE :
m_pGameMidlet.commandAction(m_pGameMidlet.m_cmdSelect, this);
break;
}
}
}
void startGame(boolean bResume, boolean bReset) {
m_pGameModel.start(bResume, bReset);
repaint();
serviceRepaints();
}
void pauseGame() {
if (!m_pGameModel.g_bPaused) {
m_pGameModel.pause();
repaint();
serviceRepaints();
}
}
protected void hideNotify() {
// SD if (!m_pGameMidlet.g_bFinished_Game && !m_pGameModel.g_bPaused) {
if (!m_pGameModel.g_bPaused && m_pGameModel.g_Game_Mode != Globals.MODE_GAMEOVER) {
m_pGameMidlet.pauseGame();
}
}
protected void showNotify() {
try {
/* Start Modified 21-03-2003 for external events */
repaint();
serviceRepaints();
//m_pGameMidlet.startApp();
/* End Modified 21-03-2003 */
} catch (Exception ex) {}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -