GameCanvas.java :  » UnTagged » meteoroid » javax » microedition » lcdui » game » Android Open Source

Android Open Source » UnTagged » meteoroid 
meteoroid » javax » microedition » lcdui » game » GameCanvas.java
package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

import org.meteoroid.core.DeviceManager;

public abstract class GameCanvas extends Canvas {
  public static final int UP_PRESSED = 1 << Canvas.UP;
  public static final int DOWN_PRESSED = 1 << Canvas.DOWN;
  public static final int LEFT_PRESSED = 1 << Canvas.LEFT;
  public static final int RIGHT_PRESSED = 1 << Canvas.RIGHT;
  public static final int FIRE_PRESSED = 1 << Canvas.FIRE;
  public static final int GAME_A_PRESSED = 1 << Canvas.GAME_A;
  public static final int GAME_B_PRESSED = 1 << Canvas.GAME_B;
  public static final int GAME_C_PRESSED = 1 << Canvas.GAME_C;
  public static final int GAME_D_PRESSED = 1 << Canvas.GAME_D;
  
  private int keyState;
  
  protected GameCanvas(boolean suppressKeyEvents) {
    setDisplayableType(GAMECANVAS);
  }
  
  protected Graphics getGraphics() {
    return DeviceManager.device.getGraphics();
  }
  
  public void paint(Graphics g) {
  }
  
  public void flushGraphics(int x, int y, int width, int height) {
    if (DeviceManager.device.getCurrentDisplayable() == this)
      DeviceManager.device.flushGraphics(x, y, width, height);
  }
  
  public void flushGraphics() {
    if (DeviceManager.device.getCurrentDisplayable() == this)
      DeviceManager.device.flushGraphics();
  }
  
  public int getKeyStates() {
    return keyState;
  }
  
  public void setKeyStates(int keyState) {
    this.keyState = keyState;
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.