BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 01-29-2009, 10:47 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2007
Location: Delaware
Model: 8310
Carrier: AT&T
Posts: 23
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post J2ME getKeyStates equivalent using RIM API's

Please Login to Remove!

I just recently converted many of my games to use the blackberry API's instead of the J2ME API's and there is only one thing that I cant find a nice equivalent with. It's the getKeyStates() in the GameCanvas class. Is there an quivalent in the MainScreen or FullScreen BlackBerry API classes?

getKeyStates() allows you to check if any key (multiple keys too!) is down or up. And please folks, I'm not looking for the keydown or keypressed events as this is a little different. I want the equivalent of getKeyStates().

The goal is to have the user press a key on the blackberry and move them in that direction until the user releases the key. A smooth movement.. not how when you press a key, pause, and then the key repeats itself.

Also, I tried the keydown and keyup events and that is a workaround but sometimes it fails by not recognizing the keyup event if you open up a menu or whatever.

Thanks,

Ron
Offline  
Old 01-29-2009, 11:24 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I'm not familiar with getKeyStates(), but did try overriding keyChar() in your screen class?

This will give you an event for each key pressed.
Offline  
Old 01-29-2009, 12:08 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2007
Location: Delaware
Model: 8310
Carrier: AT&T
Posts: 23
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. keyChar() does give you the key that was pressed but again, I want smooth operation. Press and hold any letter on your keyboard to make it repeat. Do you see how it pauses before it starts repeating? Try it! That's the movement that I'm trying to avoid.

The getKeyStates() function in the J2ME API gave you a state on or off for each key. So there would be no pause here... I know the RIM API's must have an equivalent.
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.