×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    12

    canvas gameaction

    I am trying to write a scrabble game.
    As the board for the scrabble game, I have draws grid using Canvas class.

    How can I detect that which a letter ( A, B, c , d, ....) the user types on the squares of the board?
    In the canvas, we can use game Action Constant as only
    UP
    DOWN
    LEFT
    RIGHT
    FIRE
    GAME_A
    GAME_B
    GAME_C
    GAME_D

    How can we determine whether we type a letter or not and which character we type?

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: canvas gameaction

    Well, there are the key handlers in the canvas you can use in order to get the key you pressed. For your purposes may be you have to write some code as per the key code that the device written,like if you want to draw that the user has pressed z or m or p then as per the key code you have to move ahead.

    What I meant is as it is Here.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: canvas gameaction

    Quote Originally Posted by 7.light View Post
    I am trying to write a scrabble game.
    As the board for the scrabble game, I have draws grid using Canvas class.

    How can I detect that which a letter ( A, B, c , d, ....) the user types on the squares of the board?
    In the canvas, we can use game Action Constant as only
    UP
    DOWN
    LEFT
    RIGHT
    FIRE
    GAME_A
    GAME_B
    GAME_C
    GAME_D

    How can we determine whether we type a letter or not and which character we type?
    In Canvas class you can overwrite the KepPressed methods like this to get to know which key is pressed?
    Code:
    public void keyPressed(int key)
    	{
    		int gameAction = getGameAction(key);
     		System.out.println("KEY: " + key + ", " + gameAction);
             }
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: canvas gameaction

    I strongly recommend you avoid using the Game Actions. The key code passed to keyPressed will tell you which key was pressed.

    If the device has a QWERTY keyboard, the keycode will probably be the ASCII code of the letter typed.

    If the device as a numeric pad only, there will be no indication of typing a letter, only 0-9, * or #.

    The official Scrabble game just uses the d-pad to select tiles from the user's set, rather than allowing the user to type.

    Graham.

Similar Threads

  1. canvas help (multiple canvas)
    By tmf81 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2009-08-25, 07:58
  2. Canvas: How to show only a image not a canvas background
    By ricardopcunha in forum Mobile Java General
    Replies: 13
    Last Post: 2009-02-16, 08:59
  3. How to create a partly transparent Canvas to lay on top of another Canvas?
    By mkleijer in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-05-22, 07:00
  4. How to call one canvas from another canvas
    By smart_aju2007 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-02-04, 14:38
  5. gameAction bug in 6230 concept
    By jozart in forum Mobile Java General
    Replies: 0
    Last Post: 2004-01-28, 04:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×