BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-18-2007, 05:33 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default game keys in custom item

Please Login to Remove!

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();
        }
    }
Offline  
Old 12-18-2007, 02:43 PM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

why don't you try sysouting the int that occurs on keyPressed of "FIRE"? it doesn't have to match FIRE, it just has to match whatever the device thinks is FIRE.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.