- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
barcode generator in c# code project ADDING A PROFESSIONAL LOOK AND FEEL in Font
CHAPTER 10 ADDING A PROFESSIONAL LOOK AND FEEL Data Matrix ECC200 Generator In None Using Barcode generator for Font Control to generate, create ECC200 image in Font applications. www.OnBarcode.comBarcode Maker In None Using Barcode creator for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.com// or advances to the next board if a board // is done: try { if(myGameOver) { reset(); flushKeys(); myDungeon.resumeGame(); } else { setMenuMode(); } } catch(Exception e) { myDungeon.errorMsg(e); } } } /** * Respond to softkeys in the case where * lcdui commands are used instead of custom * graphical softkeys. */ public void commandAction(Command c, Displayable s) { try { if(c == myMenuCommand) { setMenuMode(); } else if(c == myOkCommand) { removeCommand(myOkCommand); addCommand(myMenuCommand); reset(); flushKeys(); myDungeon.resumeGame(); } else if(c == myExitCommand) { myDungeon.quit(); } } catch(Exception e) { myDungeon.errorMsg(e); } } } You can see that another advantage of this version over the version in 5 is that the timer is also drawn with a set of five sprites (all using the same image) instead of being drawn with one of the platform s built-in fonts onto an ugly black bar drawn across the bottom of the screen. Figure 10-7 shows the difference. Draw Data Matrix In None Using Barcode generator for Font Control to generate, create DataMatrix image in Font applications. www.OnBarcode.comPainting Code-39 In None Using Barcode creation for Font Control to generate, create Code-39 image in Font applications. www.OnBarcode.comCHAPTER 10 ADDING A PROFESSIONAL LOOK AND FEEL
Encoding Denso QR Bar Code In None Using Barcode generator for Font Control to generate, create QR Code JIS X 0510 image in Font applications. www.OnBarcode.comEAN 128 Generation In None Using Barcode maker for Font Control to generate, create EAN128 image in Font applications. www.OnBarcode.comFigure 10-7. The difference in how the timer number appears in the two versions The trickiest part of the menu code in Listing 10-8 is the implementation of the softkeys, explained in the next section. PDF 417 Maker In None Using Barcode creator for Font Control to generate, create PDF-417 2d barcode image in Font applications. www.OnBarcode.comUSPS Confirm Service Barcode Generator In None Using Barcode encoder for Font Control to generate, create USPS PLANET Barcode image in Font applications. www.OnBarcode.comImplementing Softkeys
Make Data Matrix In Java Using Barcode generator for Java Control to generate, create Data Matrix image in Java applications. www.OnBarcode.comData Matrix Creator In .NET Using Barcode encoder for VS .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications. www.OnBarcode.comNearly every MIDP device uses a system of softkeys to drive its built-in GUI. A softkey is a physical button on the device whose function changes depending on the context. The button corresponding to the softkey is generally placed right next to the screen so that the program can display the current label for it such as Exit, Options, or OK. A typical platform has two softkeys a right softkey and a left softkey at the base of the screen. When writing your own custom GUI, naturally you want to be able to implement the softkey functionality so that you can be sure that the softkey labels match the look of the rest of the graphical components. Unfortunately, the designers of MIDP decided that they didn t want to make it easy for you to do this. The philosophy seems to be that the softkeys are a platformspecific implementation detail that you don t need to know about, and if you start fiddling with them, you can mess up the platform s consistent user experience by perhaps putting your Exit key on the left when the platform normally puts it on the right, or you might assume the softkeys are at the bottom of the screen when for a particular platform they re at the top. So MIDP encapsulates softkeys (and possibly other related input features) in Command objects and says in essence We ll handle them you don t touch them. Linear Encoder In Java Using Barcode drawer for Java Control to generate, create Linear Barcode image in Java applications. www.OnBarcode.comGTIN - 13 Recognizer In .NET Framework Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comCHAPTER 10 ADDING A PROFESSIONAL LOOK AND FEEL
UPC Code Creation In .NET Framework Using Barcode drawer for .NET Control to generate, create Universal Product Code version A image in .NET framework applications. www.OnBarcode.comBarcode Decoder In Visual Basic .NET Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in .NET applications. www.OnBarcode.comHowever, since so many devices use this same consistent design of placing the softkeys at the bottom left and bottom right of the screen, it s natural to want to try to implement them yourself to create a consistent, attractive look for your game. It would have been nice if the designers of MIDP had at least thrown in some minimal support such as a system property you can query to determine whether the platform uses standard (bottom left and bottom right) softkeys, and then provide the corresponding key constants in the GameCanvas class. As it is, it s possible to receive and interpret the softkey events, but you have to do some additional work, and the resulting code isn t terribly portable. Essentially you have to customize the JAR file for every target device (or at least every manufacturer) that you d like to use custom softkeys on. Here s how to do it. If you look at Listing 10-8, you ll see that in addition to querying for key states (as in the corresponding class in 5), the keyPressed() method is also implemented. This is because the return value of the getKeyStates() method only returns information about the standard Java key constants. However, the AMS calls the keyPressed() method with the platform s raw keycode integer corresponding to the key that was pressed. Since these keycodes vary from one device to the next, you usually follow with the getGameAction class to translate the platform-specific keycode into a recognizable Java constant (as explained in the section Using the Graphics and Canvas Classes from 2). But if you happen to know the current device s codes for the left and right softkeys, this is where you use that information. Figuring out what keycodes your game should be using at any given moment is a two-step process: (1) identify the platform, and (2) load and use the correct keycode values for the current platform. Identifying the platform is a challenge all its own, discussed in the Identifying the Platform sidebar earlier. Then figuring out the keycodes for all of your target devices is a separate challenge. Some manufacturers (Sony Ericsson, for example) publish developer guides that contain the keycodes. Additionally, there are online databases listing the keycodes for many popular devices, such as the device database on the J2ME Polish web site (see the Using J2ME Polish sidebar). Many devices follow the WTK s example for their keycode mapping: -6 for the left softkey and -7 for the right softkey. (These are the values used by Sony Ericsson, for example.) But many don t. My Sagem my700x, for example, uses exactly the reverse. Once you know the keycodes for the current device, implementing the softkeys is a snap. As you can see in Listing 10-8, you set your canvas to full-screen mode, then paint on the softkey labels in the lower right and left corners of the screen, and handle the softkey actions in the keyPressed() method. However, it s good to provide a fallback for the case where the game is running on a device that you can t identify and/or don t have the keycodes for. In this case, we can still use the custom menu code, but the menu screen is put up and down using standard lcdui Command objects, implemented in the commandAction() method of Listing 10-8. It s not quite as pretty, but it s not the end of the world. Figure 10-8 shows what that looks like. QR Generation In Java Using Barcode generator for Java Control to generate, create QR image in Java applications. www.OnBarcode.comGenerate EAN / UCC - 14 In None Using Barcode generator for Microsoft Excel Control to generate, create GS1-128 image in Microsoft Excel applications. www.OnBarcode.comANSI/AIM Code 39 Printer In .NET Using Barcode maker for ASP.NET Control to generate, create Code-39 image in ASP.NET applications. www.OnBarcode.comPaint Code-128 In None Using Barcode maker for Software Control to generate, create Code128 image in Software applications. www.OnBarcode.com1D Generator In VB.NET Using Barcode drawer for Visual Studio .NET Control to generate, create 1D Barcode image in .NET applications. www.OnBarcode.comPrint GS1 RSS In Java Using Barcode creation for Java Control to generate, create GS1 DataBar Truncated image in Java applications. www.OnBarcode.com |
|