Ghosts.java

/*
 * Copyright © 2012 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners.
 * See LICENSE.TXT for license information.
 */
package com.nokia.example.ghosts;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/*
 * Ghosts sample MIDlet.
 *
 * The Ghosts mini-game demonstrates how to enable and use Nokia-specific
 * multipoint touch in LCDUI midlets.
 *
 * This is a simple game where the player should shoot a ghost by moving the crosshair
 * over the screen and firing. The crosshair is controlled by an on-screen gamepad
 * which emulates an analog stick and fire button on multipoint touch-enabled Canvas.
 *
 * Multipoint touch events are enabled by JAD attribute
 *
 *    Nokia-UI-Enhancement: EnableMultiPointTouchEvents
 *
 * To improve touch responsiveness, JAD attribute
 *
 *    Nokia-MIDlet-Tap-Detection-Options: 0, 0
 *
 * is used to disable tap detection.
 *
 * The game is implemented in following classes:
 *
 *  - Scene       - Main game logic, generates game's world-clock for rest of games classes,
 *                  passes pointer events (received though pointerPressed(), pointerDragged()
 *                  and pointerReleased() methods) to the Gamepad. Retrieves pointer number
 *                  information in method getPointerEventId().
 *
 *  - Gamepad     - Multipoint touch on-screen gamepad. Uses pointer events from Scene to
 *                  update analog stick position and fire button status.
 *
 *  - Crosshair   - Crosshair used for aiming, uses player input provided by Gamepad.
 *
 *  - Ghost       - Implements Game's non-player character behavior.
 *
 *  - Point, Size - Auxiliary classes used for position and size handling.
 *
 */
public class Ghosts extends MIDlet
{
    private Scene scene = null;
    private Display display;

    public Ghosts()
    {
        this.display = Display.getDisplay(this);
        this.scene  = new Scene(this);
        this.display.setCurrent(this.scene);
    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
    {
        this.display.setCurrent(null);
        this.scene = null;
        this.display = null;
    }

    protected void pauseApp()
    {
    }

    protected void startApp() throws MIDletStateChangeException
    {
    }
}