⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamecanvas.java

📁 J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * @(#)GameCanvas.java 1.7
 *
 * Copyright (c) 2001-2004 Sony Ericsson Mobile Communication AB (SEMC).
 *
 * German Branch
 * Heisenbergbogen 1, Aschheim 85609, Munich, Germany.
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * SEMC. ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with SEMC.
 *
 * @author  Sudip Sen Gupta, Rohit Kanwar, Keshav.
 * @version 1.7, 10/10/2003
 */


package com.sonyericsson.erix;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.StringItem;

/**
 * The GameCanvas class encapsulates the display fuinctionality of the
 * entire application.
 */

public class GameCanvas extends Canvas {

    /**
     * Splash Screen Mode.
     */
    public static final int SPLASH_SCREEN = 1;

    /**
     * Main Menu Screen Mode.
     */
    public static final int MENU_SCREEN = 2;

    /**
     * Attract Mode.
     */
    public static final int ATTRACT_SCREEN = 3;

    /**
     * Game Loading Mode.
     */
    public static final int LOADING_GAME_SCREEN = 4;

    /**
     * Game Play Mode.
     */
    public static final int GAME_SCREEN = 5;

    /**
     * The mode where the user has to choose the difficulty level of
     * the new game to be started.
     */
    public static final int START_GAME_SCREEN = 6;

    /**
     * High Score List Mode.
     */
    public static final int HIGH_SCORE_LIST_SCREEN = 7;

    /**
     * Settings Mode.
     */
    public static final int SETTINGS_SCREEN = 8;

    /**
     * Game Language Selection Mode.
     */
    public static final int GAME_LANGUAGE_SELECTION_SCREEN = 9;

    /**
     * Game Audio Selection Mode.
     */
    public static final int GAME_AUDIO_SELECTION_SCREEN = 10;

    /**
     * High Score Entry Mode.
     */
    public static final int HIGH_SCORE_ENTRY_SCREEN = 11;

    /**
     * Help Mode.
     */
    public static final int HELP_SCREEN = 12;

    /**
     * Game Paused Mode.
     */
    public static final int PAUSE_SCREEN = 13;

    /**
     * Game Wait Mode.
     */
    public static final int WAIT_SCREEN = 14;

    /**
     * Mode for confirming whether the user wants to reset the high scores.
     */
    public static final int RESET_CONF_SCREEN = 15;

    /**
     * Mode for displaying the User Authentication Form.
     */
    public static final int USER_AUTHENTICATION_SCREEN = 16;

    /**
     * Mode for displaying the authentication-related help text.
     */
    public static final int AUTHENTICATION_HELP_SCREEN = 17;

    /**
     * Mode for displaying the result of the highscore upload operation.
     */
    public static final int HIGHSCORES_UPLOAD_RESULT_SCREEN = 18;

    /**
     * Mode for indicating to the user that their highscores are being
     * uploaded to the server.
     */
    public static final int HIGHSCORES_UPLOAD_PROGRESS_SCREEN = 19;

    /**
     * Game difficulty level.
     */
    public byte m_bytDifficulty;

    /**
     * Keeps the reference of List of Start Menu strings.
     */
    public List m_objListStartMenu;

    /**
     * Keeps the reference of Language List used by Language preference screen.
     */
    public List m_objListLanguage;

    /**
     * Keeps the reference of High score reset form.
     */
    public Form m_objHighScoreResetForm;

    /**
     * Keeps the reference of Setting screen menu.
     */
    public List m_objListSettingsMenu;

    /**
     * Keeps the reference of the list for game difficulty level options.
     */
    public List m_objListGameDifficulty;

    /**
     * Keeps the reference of Audio preferences selection menu.
     */
    public List m_objListAudioMenu;

    /**
     * Keeps the reference of 'Back' Command to be used
     * by the various screens of application.
     */
    public Command objBackCmd;

    /**
     * Keeps the reference of dummy 'Back' Command to be used
     * by the various screens of application.
     */
    public Command objBackDummyCmd;

    /**
     * Keeps the reference of 'Send' Command to be used
     * by the High score screen.
     */
    public Command objSendCmd;

    /**
     * Keeps the reference of 'Back' Command to be used
     * by the High Score List Screen.
     */
    public Command objHighScoreBackCmd;

    /**
     * Keeps the reference of dummy 'Back' Command to be used
     * by the High Score List Screen.
     */
    public Command objHighScoreBackDummyCmd;

    /**
     * Keeps the reference of 'Reset' Command to be used
     * by the High score screen.
     */
    public Command objResetCmd;

    /**
     * Keeps the reference of 'Yes' Command to be used
     * in the confirmation screen for resetting high scores.
     */
    public Command objYesCmd;

    /**
     * Keeps the reference of 'No' Command to be used
     * in the confirmation screen for resetting high scores.
     */
    public Command objNoCmd;

    /**
     * Keeps the reference of dummy 'No' Command to be used
     * in the confirmation screen for resetting high scores.
     */
    public Command objNoDummyCmd;

    /**
     * Keeps the reference of 'the 'Help' command
     * present on the User Authentication Form.
     */
    public Command objHelpCmd;

    /**
     * Keeps the reference of 'OK' Command.
     */
    public Command objOkCmd;

    /**
     * Keeps the reference of 'Cancel' Command.
     */
    public Command objCancelCmd;

    /**
     * Keeps the reference of dummy 'Cancel' Command.
     */
    public Command objCancelDummyCmd;

    /**
     * Keeps the reference of 'Pause' Command to be used by the Game screen.
     */
    public Command objPauseGameCmd;

    /**
     * Keeps the reference of 'Resume' Command to be used by the Game screen.
     */
    public Command objResumeGameCmd;

    /**
     * Keeps the reference of Help Form.
     */
    public Form m_objHelpForm;

    /**
     * Keeps the reference of Highscore Entry Form.
     */
    public Form m_objHighScoreEntryForm;

    /**
     * Keeps the reference of User Authentication Form.
     * When a user wishes to upload scores to the Highscores server,
     * this form is presented to them for entry
     * of their CIP Server username and password,
     * with which they are authenticated with the server.
     */
    public Form m_objUserAuthenticationForm;

    /**
     * Keeps the reference of the form
     * on which the help for authentication is displayed.
     */
    public Form m_objAuthenticationHelpForm;

    /**
     * Keeps the reference of the form
     * on which the confirmation or error messages
     * describing the outcome of the Highscores upload operation
     * are displayed.
     */
    public Form m_objHighscoresUploadResultForm;


    /**
     * Keeps the reference of the form which indicates to the user that
     * their highscores are being uploaded to the server, and also
     * provides the facility to cancel the upload.
     */
    public ProgressForm m_objHighscoresUploadProgressForm;

    /**
     * Reference of the Game Engine object.
     */
    public GameEngine m_objEngine;

    /**
     * Number of frames in the animation shown
     * when the user achieves a high score.
     */
    private int m_nFrameCount;

    /**
     * Indicates whether the 'Done' Command is to be added
     * to the High Score List screen, when it is displayed again
     * after termination of the  attract mode.
     */
//below statement commented because Midori does not have attract mode.
//    private boolean m_bIsDonePresent;

    /**
     * Keeps the reference of text field used
     * for entering player's name in High score entry screen.
     */
    private TextField m_objPlayerNameText;

    /**
     * Keeps the reference of StringItem used
     * to show high score in High Score Entry screen.
     */
    private StringItem m_objHighScoreStrItem;

    /**
     * The StringItem used for displaying authentication prompt
     * on the user authentication form.
     */
    private StringItem m_objAuthenticationPromptStringItem;

    /**
     * The TextField used for accepting the user's userId
     * for authenticating with the highscore server.
     */
    public TextField m_objUseridTextField;

    /**
     * The textfield for accepting the user's password
     * for authenticating with the highscore server.
     */
    public TextField m_objPasswordTextField;

    /**
     * The maximum length individualy allowed for the userid and password
     * on the User Authentication Form. This restriction
     * is present on the server, so is implemented on the client too.
     */
     private final int USERID_PASSWORD_MAX_LENGTH = 40;

    /**
     * The StringItem used for displaying the authentication help text
     * on the Authentication Help form.
     */
    private StringItem m_objAuthenticationHelpStringItem;

    /**
     * The StringItem used for indicating to the user that their highscores
     * are being uploaded to the server.
     */
    private StringItem m_objUploadProgressStringItem;

    /**
     * The StringItem used for displaying the first part of the message
     * regarding the result of an attempted Highscores upload operation.
     */
    private StringItem m_objUploadResultPartOneStringItem;

    /**
     * The StringItem used for displaying the second part of the message
     * regarding the result of an attempted Highscores upload operation.
     */
    private StringItem m_objUploadResultPartTwoStringItem;

    /**
     * The StringItem used for displaying the third part of the message
     * regarding the result of an attempted Highscores upload operation.
     */
    private StringItem m_objUploadResultPartThreeStringItem;

    /**
     * A flag to switch between the two colors
     * in which a new High Score entry is displayed,
     * for providing a "blinking" effect to the entry.
     */
    public boolean m_bBlink;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -