📄 erixmidlet.java
字号:
/**
* ISO 639-1 names for the supported languages.
*/
public final String[] m_arrstrLanguageISOName = {"en", "fr"};
/**
* Game Audio On Selection
*/
private final byte GAME_AUDIO_ON = 0;
/**
* Game Audio Off Selection
*/
private final byte GAME_AUDIO_OFF = 1;
/**
* High Score Count
*/
private final int NO_OF_HIGH_SCORE = 5;
/**
* Indicates no of variables that are used to keep the status of the game at any time
*/
private final int NO_OF_GAME_VARIABLE = 4;
/**
* Stores the index of the selected menu item of the current screen, which is used to
* highlight the menu while traversing backwards.
*/
private int m_nSelectedIndex ;
/**
* Keeps the reference of the High score store for the game.
*/
private static RecordStore m_objErixHighScoreStore;
/**
* Keeps the reference of the Setting/preferences Store for the game.
*/
private static RecordStore m_objErixPrefStore;
/**
* Keeps the reference of the game status data.
*/
private static RecordStore m_objErixGameDataStore;
/**
* Stores the unique serial number associated with an instance of the game.
*/
private static RecordStore m_objErixSerialNoStore;
/**
* Recordstore that contains the status of the last highscore upload.
*/
private static RecordStore m_objErixUploadStatusStore;
/**
* The name of the Recordstore that contains
* the status of the last highscore upload.
*/
private final String UPLOAD_STATUS_STORE_NAME = "UploadStatus";
/**
* Recordstore that contains the parameters related to the UI of
* the Highscores upload functionality.
*/
private static RecordStore m_objErixUploadUiStore; //changed from public - Patel
/**
* The name of the Recordstore that contains
* the parameters related to the UI of
* the Highscores upload functionality.
*/
private final String UPLOAD_UI_STORE_NAME = "UploadUi";
// The recordId numbers of the various application data stored in the RMS
// Currently, only the Highscores upload UI strings are managed with this mechanism.
/**
* RecordId for the authentication prompt.
*/
public final byte AUTHENTICATION_PROMPT = 1;
/**
* RecordId for the authentication help.
*/
public final byte AUTHENTICATION_HELP = 2;
/**
* RecordId for the last used username.
*/
public final byte LAST_USED_USERNAME = 3;
// IMPORTANT: Update this number here everytime a new record
// is planned to be added the RecordStore
/**
* The highest RecordId with which a record
* is stored in the "Upload Ui" RecordStore
*/
private final byte HIGHEST_RECORDID_USED = 3; // IMPORTANT: Always update
/**
* Used to display splash screen
*/
private boolean m_bSplashScreen;
/**
* Keeps reference of the Displayable object
*/
private Display m_objDisplay;
/**
* Keeps reference of the GameCanvas object
*/
public GameCanvas m_objGameCanvas;
/**
* Indicates whether high score is present or not
*/
private boolean m_bHighScoresPresent;
/**
* Keeps refrence of byte array, which has all the language specific strings as
* sequence of bytes
*/
private byte m_arrReadFromStream[];
/**
* Keeps refrence of byte array, which has the random positions of Enemy as
* a sequence of bytes
*/
private byte m_arrRandomNumberStream[];
/**
* Keeps refrence of string array, which has all the language specific strings.
*/
private String m_arrLanguageStrings[];
/**
* This flag indicates whether the current game has been saved into
* the RMS in the current session. If the game ends and this flag is
* set (i.e., game was saved), it means that the game in the RMS
* is the one just completed, and so it is deleted. On the other hand,
* if at the end of the game, this flag is not set (i.e., the game
* was not saved), it means the current game has ended without
* any progress in level from the one in which it started. In that
* case, the existing saved game is not deleted.
*/
boolean m_bCurrentGameSaved;
/**
* Flag to indicate whether the language settings stored or not
*/
private boolean m_bIsLanguageSet;
/**
* For storing the current score
*/
public long m_lGameScore;
/**
* Keeps reference of GameEngine Object
*/
private GameEngine m_objGameEngine;
/**
* Stores the game difficulty
*/
private int m_nGameDifficulty;
/**
* The object that is used to transmit the highscores to the server,
* over HTTP.
* This has "public" access because it is used by the GameCanvas object
* to retrieve some information from the score transmitter object.
*/
public HTTPScoreTransmitter m_objHTTPScoreTransmitter;
/**
* Flag for the midlet thread.This flag is set to true whenever application
* exits from the menu or the back command in the start screen.
*/
private boolean m_bExitMidlet;
/*
* Flag to notify the midlet to start the clean up activity
*/
private boolean m_bdoCleanUp;
/*
* Flag to notify the that the application is trying to resume after call to pauseApp
*/
private boolean m_bResumeApp;
/*
* Keeps the sleep time of midlet thread for attract mode,Splash screen mode and
* the animation in the high score screen.
*/
private int m_nSleepTime;
byte bytHTTPStatus;
// Static code block to allow garbage collection at application startup.
// This is done to make sure that if the application is launched
// immediately after exiting this or another Java application,
// an OutOfMemoryError does not happen.
/*
static {
try {
System.gc();
Thread.sleep(300);
} catch (Exception e) {
}
}
*/
/**
* Constructor.
*/
public ErixMIDlet() {
m_bdoCleanUp = true;
m_bResumeApp = false;
m_objGameEngine = null;
m_lStartTime = 0;
m_nBlinkIndex = -1;
nGameSplashScreenWait = 50;
nWaitCount = 0;
m_nKeyPressWait = 0;
m_bProcessing = true;
m_bMenuOn = false;
m_nSelectedIndex = 0;
/* Store the reference of the Display object that is unique to this MIDlet */
m_objDisplay = Display.getDisplay(this);
/* Initialising all data structures */
m_arrHighScores = new long[NO_OF_HIGH_SCORE];
m_arrDiffLevelHighScores = new byte[NO_OF_HIGH_SCORE];
m_arrLevelForHighScores = new byte[NO_OF_HIGH_SCORE];
m_arrGameData = new byte [NO_OF_GAME_VARIABLE];
m_arrHighScoreNames = new StringBuffer[NO_OF_HIGH_SCORE];
m_objNewNameStringBuffer = new StringBuffer();
m_arrGameData[0] = 1; // Setting default level to 1
for (int i=0;i<NO_OF_HIGH_SCORE;i++ ) {
m_arrHighScoreNames[i] = null;
}
/* Setting the game language to english(default) */
m_nGameLanguage = GAME_LANGUAGE_ENGLISH;
/* Initializing the default audio setting to 'Off' */
m_nAudioSetting = 1;
/* Variable denoting whether there is any highscores present in the RMS */
m_bHighScoresPresent = false;
/* To show the Splash screen on display */
m_bSplashScreen = true;
/* To disable the Animation display at start */
m_bAnimScreen = false;
/* To disable the Attract mode at start */
m_bAttractMode = false;
/* To show the 'Send' menu item in High screen score list
* Value is set to false. Because, the Send should not be displayed when
* the appplication is launched for the first time.
*/
m_bSendMenu = false;
m_bClearMenu = false;
m_nGameDifficulty = 0;
} // end of ErixMIDlet constructor
/**
* Signals the ErixMIDlet that it has entered the active state.
* In the active state ErixMIDlet creates and holds all the resources needed during its lifetime.
* The startApp() method
* <ul>
* <li> Initialises the GameCanvas object,
* <li> sets the mode of the application to 'Splash screen mode'
* </ul>
* Once the splash screen is being displayed, this method
* <ul>
* <li> creates all other required objects,
* <li> retrieves the application settings from the RMS,
* <li> reads the UI strings for the language preferred by the user (or for English, if the application is being used for the first time), and
* <li> retrieves the saved game (if any) the RMS,
* </ul>
*/
protected void startApp(){
// m_bResumeApp will be true when Midlet enters active
// state from paused state
if (!m_bResumeApp) {
/* Retrieve high scores, if any, from the RMS */
m_bHighScoresPresent = retrieveHighScores();
//System.out.println("m_bHighScoresPresent: " + m_bHighScoresPresent);
// All the below initialisation is required to avoid
// crashing of application on multiple launch and exit.
bytHTTPStatus = retrieveHTTPStatus();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -