hi i am trying to implement a basic game action key in my keypressed method but it says it cant find the game action key of FIRE
Here is my code below. cant i use the game keys such has LEFT RIGHT UP DOWN FIRE keys?
Code:
private Image button;
private blackjack root;
/** Creates a new instance of validate */
public validate( String label, blackjack midlet)
{
super( label );
this.root = midlet;
}
// Returns the minimal height of the content
// area.
protected int getMinContentHeight()
{
return 40;
}
// Returns the minimal width of the content
// area.
protected int getMinContentWidth()
{
return 40;
}
// Returns the preferred height of the content
// area. A tentative value for the opposite
// dimension -- the width -- is passed to aid
// in the height calculation. The tentative value
// should be ignored if it is -1.
protected int getPrefContentHeight( int width )
{
return getMinContentHeight();
}
// Returns the preferred width of the content
// area. A tentative value for the opposite
// dimension -- the height -- is passed to aid
// in the width calculation. The tentative value
// should be ignored if it is -1.
protected int getPrefContentWidth( int height )
{
return getMinContentWidth();
}
// Draws the item's content area, whose dimensions
// are given by the width and height parameters.
protected void paint( Graphics g, int width, int height )
{
try
{
button = Image.createImage("/validate.png");
} catch (IOException ex)
{
ex.printStackTrace();
}
// g.setColor( 255, 255, 255 );
// g.fillRect( 0, 0, width, height );
}
protected void keyPressed(int k)
{
int g = getGameAction( k );
if( g == FIRE || k == 10 )
{
//login to the game
root.login();
}
}