J 2 MEゲーム開発のボタンイベント

3669 ワード

package com.sliw.graphics;



import javax.microedition.lcdui.Canvas;

import javax.microedition.lcdui.Graphics;



public class KeyEventCanvas extends Canvas{



    public static final int KEY_UP = -1;

    public static final int KEY_DOWN = -2;

    public static final int KEY_LEFT = -3;

    public static final int KEY_RIGHT = -4;

    public static final  int mkey0 = 48;

    public static final  int mkey1 = 49;

    public static final  int mkey2 = 50;

    public static final  int mkey3 = 51;

    public static final  int mkey4 = 52;    

    public static final  int mkey5 = 53;

    public static final  int mkey6 = 54;

    public static final  int mkey7 = 55;

    public static final  int mkey8 = 56;

    public static final  int mkey9 = 57;

    

    

    

    protected void paint(Graphics arg0) {

        // TODO Auto-generated method stub

        

    }



    /**

     *   

     */

    protected void keyPressed(int keyCode) {

        // TODO Auto-generated method stub

        System.out.println("keyCode=" + keyCode);

        super.keyPressed(keyCode);

    }

    

    /**

     *   

     */

    protected void keyReleased(int keyCode) {

        // TODO Auto-generated method stub

        super.keyReleased(keyCode);

    }

}


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }