views:

48

answers:

2

Hi guys,

I have a small Java ME project (a game) that I'd like to port to BlackBerry, where I don't have any experience yet. I have identified 2 categories of devices that I would like to support, based on whether or not they support touch:
1. 320x240 and 480x360 (non-touch)
2. 360x480 (touch)

For the non-touch devices, the changes would be minimal (I will only re-map the keys to control the game), but with touch devices it seems tricky. I assume I will have to have 2 different code bases, since pre-4.7 devices didn't have touch API, and am looking for a way to minimize the amount of code I have to write. Ideally I would like to have only 1 project (is that possible)? Any suggestions on how to organize this project would be very appreciated. Thank you.

A: 

It's not necessary to have two separate builds to support both Touch and Non-Touch devices. You can implement theTouchEvent, NavigationMovement, and KeyDown methods in the appropriate classes to handle both interaction methods. The TouchEvent method would handle all touchscreen related interaction and the NavigationMovement and KeyDown methods would provide interaction with the devices that have a keyboard and a trackpad.

The Blackberry Torch has both a touchscreen and a trackpad which would even further complicate the separate build method.

redwoolf
Thank you redwoolf. Won't there be a problem with pre v4.7 devices that don't know the touch API at all, and I have the usings in that project? Won't the app crash on those older devices because of missing bindings? Thank you!
Levon
A: 

You're right, if you're trying to support pre-4.7 devices your app won't work if it's using the touch API. You can surround touch-specific code with something like

//#ifdef STORM
import net.rim.device.api.ui.TouchEvent;
//#endif

I use Netbeans. The "STORM" definition is the name of my NB configuration, but you can define your own, etc... Sorry to just paste links, but I don't know how to do it in Eclipse.:

http://docs.blackberry.com/en/developers/deliverables/12002/Create_Workspace_Preprocessor_Directives_927626_11.jsp

And elsewhere on SO:

http://stackoverflow.com/questions/1383277/using-preprocessor-directives-in-blackberry-jde-plugin-for-eclipse

Edit: I know this might seem like a NB specific answer, but the preprocessor is actually supported by the BlackBerry tools in general.

spacemanaki
Thank you spacemanaki, for shedding some light and for useful links. I will try that and add a comment later when I figure it out.
Levon
Np, good luck. Switching to Eclipse is on my TODO list, I'll update if I get to it soon.
spacemanaki