Based on the Nokia mobile phone game development step by step-[job is reposted]
Abstract: Based on the Nokia mobile phone game development step by step-[job is reposted]
Based on the Nokia mobile phone game development-step by step
Author: wayne Source: yesky
First, game development strategy
1 game action (Action) use
MIDP the Canvas class programmers to deal with certain key events, either as a specific incident of a low-keying code of the game either as abstract movements. FullCanvas Nokia is the full-screen canvas (FullCanvas) category, it is inherited from the Canvas class.
Round game in the system or do not need more than four direction keys (Upper and Lower, left, right) of the game, the best use of the keyboard code directly to control the game action. Action games can be used abstract examples include the international chess games and quizzes and puzzle games, which are using the direction keys to scroll the screen or move.
Game action should only be the need for rapid response in the use of the game. This is because the choice of equipment may mapping of the game moves quickly to requests for action of the game does not apply. And, if requested ramp of a game or the direction keys of this game is a fast-paced action games, then hand the game to a mobile gaming needs of the role of one hand the need to perform other tasks, such as shooting, opened the door, and so on, then on the need to use the keyboard code directly. Reason is that the MIDP does not inclined action of the game, and game action mapping is designed for the use of a hand.
When using the keyboard code directly of the incident, must pay special attention to application portability.
Between different devices in the layout of the keyboard is very different (see Figure 1, are two different phone keyboard layout). Developers can allow users to define their own keys in the game the way to solve the problem. This can be in the game or the game before the start of the "choice" in the pages completed.
Keyboard code and game action in the same application procedures should never mix.
Figure 1, different mobile phone keyboard layout
2 Description of the game action
A MIDlet application by calling the Canvas method to detect what code mapped to the keyboard applications running game in the abstract movement:
Public static int getGameAction (int keyCode);
Canvas class-action games abstract definition: UP, DOWN, LEFT, RIGHT, FIRE, and so on.
Game Developers should know MIDP 1.0 specification in a problem. This class defines the code into the keyboard to move the game, also defines the action to the keyboard into the game code approach.
Public int getGameAction (int keyCode)
Public int getKeyCode (int gameAction)
Methods getKeyCode (int gameAction) may lead to some problems, which only returned to action games based on the code of a keyboard, even if MIDP 1.0 allows more than one keyboard code to achieve. Nokia in the mobile phone, a number of individual keyboard mapping to the same code of the game action, such as "UP button" and the "2-button" has been mapped to upward moves of the game. This method can only return to one of them; return to the specific value is realized. However, if the method getGameAction (int KeyCode) the use of "UP button" and the "2-button" keyboard code as a parameter, this method will return to correct the upward movement of the game. Below look at a bad example to deepen our impression:
/ / Bad example, do not do so:
(Class TetrisCanvas extends Canvas
Int leftKey, rightKey, downKey, rotateKey;
Void init () (
/ / FOLLOWING MUST NOT BE DONE
LeftKey = getKeyCode (LEFT);
RightKey = getKeyCode (RIGHT);
DownKey = getKeyCode (DOWN);
RotateKey = getKeyCode (FIRE);
)
Public void keyPressed (int keyCode) (
If (keyCode == leftKey) (
MoveBlockLeft ();
) Else if (keyCode = rightKey) (
…
)
)
)
Below is a better solution:
(Class TetrisCanvas extends Canvas
Void init () (
)
Public void keyPressed (int keyCode) (
Int action = getGameAction (keyCode);
Switch (action)
(
Case Canvas.LEFT:
MoveBlockLeft ();
Break;
Case Canvas.RIGHT:
MoveBlockRight ();
Break;
)
)
)
This example is the MIDP 1.0 specification example, the use of getKeyCode (int gameAction) of the code dealing with the keyboard, only to return a value. If so, other possible keymap MIDlet can not be used. For example, there will be in the Nokia 7650, Nokia 7650 there are five keys and a joystick, as well as ordinary keyboard layout, and above example will return joystick rather than the value of the value of the keyboard. This is a handling of the event has nothing to do with the equipment the way, and it is a bad approach. A better solution is to keyPressed () method used getGameAction (int KeyCode). Normally, applications should be avoided getKeyCode (int gameAction) method and always use getGameAction (int KeyCode).
3 shell game and game action
Nokia mobile phone models support of the new shell game action might affect the game. Nokia first shell game can use the phone is Nokia 3510i (see Figure 2). If the phone shell game support, and equipment and there will be a game menu Settings dialog box that allows users to set up shell game on the button corresponding action of the game. Users must install the button mapping, the use of otherwise ordinary keyboard layout design of the game can not run.
Figure 2, Nokia 3510i (left) original shell (right) shell game
4 button at the same time
Many Nokia phones (such as Nokia 6310 i, 3410,7210) does not support multi-button press at the same time (that is, if you hold down the Up button, then the MIDlet will not know whether you you press Fire button). Although Nokia 7650 supports multi-button press at the same time (for example, at the same time holding down the "1" and "3" keys), but physical button on the joystick is not at the same time, according to the left and upward by, so it is impossible to have in the game of the oblique campaign, and it is upward, downward, press the left or right when the record is not a "click".
5 keys: avoid hard coding your own text string
Avoid the hard-coded text and in your MIDlet code associated with the keyboard. Canvas classes provide a return linked to each keyboard code name of the text:
Public static String getKeyName (int keyCode);
Nokia is the equipment problem is this method always returns a string English, rather than depending on the user's choice of language. Nokia equipment in the future, this might be a string of the language based on user choice. If your objective is to develop portable game, then it must be remembered getKeyName in different Nokia MIDP devices return different values.
Use full-screen canvas 6 (FullCanvas) function keys
Based on a full-screen canvas (FullCanvas) game screen function keys can only be used to screen out from the game to a different state of the screen. FullCanvas category with the Nokia user interface and application programming interface to provide a clear full-screen graphics for regional mapping, can be used for many types of games.
Inherited from Nokia user interface application programming interface FullCanvas category of the game will not screen keyboard function keys to the code (ie KEY_SOFTKEY1, KEY_SOFTKEY2, KEY_SOFTKEY3) used for game-related action, unless it is for the game to return to the menu screen .
If a MIDlet application needs to use function keys order, then you must use the default MIDP Canvas class, especially if you need to use the MIDlet label when the button. When you use the FullCanvas, you should not provide your own function keys labels.
7 international MIDlet
You may need to put your MIDlet international - for example, for different regions and languages. MIDP system attributes "microedition.locale" definition of the current regional equipment. Its value can be used System.getProperty. Method achieved. MIDP norms in the system to allow the use of an empty attribute value. However, in the Nokia MIDP implementation of the value of the space is not allowed. CLDC system attributes "microedition.encoding" defines the default character encoding equipment. Its value can be obtained using methods System.getProperty.
To learn more about the localization of MIDlet can see "Writing World Aware J2ME Applications" http://wireless.java.sun.com/midp/ttips/worldaware/ the Resource Kit. MIDP also present in the absence of a standard mechanism to deal with Resource Kit. This document the use of a simple way to user interface text separated from the main program. It Resource category (2, 9) being processed.
Join the international characteristics of a MIDlet very important, but it may increase the size of your MIDlet. If MIDlet size for a particular MIDP devices, is a problem, you may wish to have several different versions of the compiler MIDlet. Each version can be one or more regional, language localization.
8 equipment features: voice, vibration and lighting
If you use Nokia user interface application programming interface type or DeviceControl Sound (vibration, lights), you should provide a Options or Settings menu and set up an editor, to allow end-users start or cancel such settings.
However, if you use Nokia user interface application programming interface type or DeviceControl Sound (vibration and lighting) and by setting parameters JAD <> you to the installation of the game to Games menu (see 1, 11), the menu has been Games the settings allow end-users start or cancel these characteristics. Therefore application is not necessary to create their own such a characteristic. In addition to Nokia UI API technical documentation, you can also reference "Nokia UI API Programmer 's Guide", it can offer a lot of useful information.
Irrelevance of equipment 9
Nokia MIDP devices may screen size, keyboard layout and the availability of API, and so different. In order to create a portable game, in the design of the game, these differences should be taken into account.
Application systems should be asked to screen size, and to avoid drawing screen content when the hard-coded coordinates. Canvas can be used like getHeight and getWidth method to achieve this objective.
Nokia MIDP different equipment in the application programming interface great changes, developers should check the equipment to the development of platform application programming interface. It can be done, vibration, is a good example.
Try (
Class.forName ( "com.nokia.mid.ui.DeviceControl");
)
Catch (ClassNotFoundException e) (
/ / Can't use vibration because the API
/ / Is not supported in the device
)
Use MIDP Canvas inherited from the default category of the game the screen FullCanvas replace vendor-specific category, which would help improve the portability of your MIDlet However, it can not achieve the full screen.
10 Optimization
MIDP equipment memory is very limited, the use of memory to be extra cautious. The game is a very important limitation is the limited heap memory (heap memory): In order to save heap memory, object reference no longer need to be set to "null", in order that they may be targets of garbage - collection (garbage-collected) . Color screen cell phones need more memory to deal with the application of bitmaps, with a larger screen-depth and relevant internal data structure. Thus, although an application may be prepared to use a black-and-white screen cell phones, but cell phone use in color, it may consume more dynamic memory: the Nokia 7210, it shows a picture than Nokia 6310i 16 times more memory.
Developers should be applied in the design process, to take into account this factor, it should be loaded at the same time the picture of the number dropped to the lowest level. For example, the flashing screen image of the game should be able to create graphical images prior to garbage collection (all to the image by setting targets for the application of "null").
11 installation
Default under MIDlet Nokia equipment was installed under the Applications menu. If the equipment is the Games menu, MIDlet can also set the MIDlet. Jad documents in the Nokia-MIDlet-Category: Game parameters to install this menu.
Second, the steps to achieve the game
The chart below shows the MIDlet is a game in the successful installation and operation of the state after the user interface changes in the typical process. We would like to through a player's perspective on the development of mobile gaming process.
Figure 3 user interface state chart
Started the game 1
MIDlet users start, the game will show specific flashing screen. FullCanvas flashing screen is an example. It can be used to display a company logo or using animation in the presentation of the game. In addition to all the outside End keys keyboard events (MIDlet available) can be Skip flashing screen and display the main menu. It should also be used to set up a time limit, can automatically after a certain period of time to set aside flashing screen from the game screen.
GameMIDlet category is the basic game; MIDlet deal with it and deal with the life cycle of the game show. The following code is flashing screen and the framework of MIDlet games.
/ / Skeleton for the base class of game
Import javax.microedition.midlet .*;
Import javax.microedition.lcdui .*;
Public class GameMIDlet extends MIDlet (
Private Display display = null;
/ / Splash screen that starts the application
Private SplashFullCanvas splash;
Public GameMIDlet () (
Splash = new SplashFullCanvas (this);
)
Protected void startApp () (throws MIDletStateChangeException
If (display == null) (
Display = Display.getDisplay (this);
)
/ / Splash screen to the display
SetDisplayable (splash);
)
Protected void pauseApp () (
)
Protected void destroyApp (boolean p0)
(Throws MIDletStateChangeException
)
Public void setDisplayable (Displayable dl) (
Display.setCurrent (dl);
)
)
/ / Skeleton for the splash screen in Nokia Java Game
Import javax.microedition.lcdui .*;
Import java.util.Timer;
Import java.util.TimerTask;
Import com.nokia.mid.ui .*;
Public class SplashFullCanvas extends FullCanvas (
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Private Timer timer = null;
Public SplashFullCanvas (GameMIDlet parent) (
This.parent = parent;
Menu = new MainMenu (
Resources.getString (Resources.ID_GAME_NAME)
List.IMPLICIT, parent);
StartTimer ();
)
Protected void paint (Graphics g) (
/ / Do the splash screen here
)
Protected void keyPressed (int keyCode) (
Timer.cancel ();
Timer = null;
/ / All key events received set the main menu to the screen
Parent.setDisplayable (menu);
)
/ / Timer for the splash screen. Main menu is set to the display
/ / 5 seconds after.
Private void startTimer () (
TimerTask task = new TimerTask () (
Public void run () (
Parent.setDisplayable (menu);
)
);
Timer = new Timer ();
Timer.schedule (task, 5000);
)
)
2 Main Menu (MainMenu) screen
Game is the main menu contains options specific to the inherent directories ( "Continue" and "New game", "Options", "High scores," "Instructions", "About" and "Exit game"). "Continue" Only in the game will be suspended for the time being displayed. When the "Continue" Show time, it must be a directory list of elements. Heading to the main menu is the name of the game. The following code is the framework of the main menu.
/ / Skeleton for the main menu
Import javax.microedition.lcdui .*;
Public class MainMenu extends List implements CommandListener (
Private GameMIDlet parent = null;
Private GameFullCanvas game = null;
Public MainMenu (String p0, int p1, p2 String [], [] p3 Image,
GameMIDlet parent) (
Super (p0, p1, p2, and p3);
Init (parent);
)
Public MainMenu (String p0, int p1, GameMIDlet parent) (
Super (p0, p1);
Init (parent);
)
Public void init (GameMIDlet parent) (
This.parent = parent;
This.setCommandListener (this);
/ / If game paused then "Continue" should be available in
/ / Selection list
If (game! = Null & game.isPaused ()) (
If (! (This.getString (0). Equals (
New String (Resources.getString (
(Resources.ID_GAME_CONTINUE )))))
This.insert (0,
Resources.getString (Resources.ID_GAME_CONTINUE)
Null);
)
This.setSelectedIndex (0, true);
)
Else (
/ / These must be with or without icons
This.append (Resources.getString (Resources.ID_GAME_NEW), null);
This.append (Resources.getString (Resources.ID_GAME_OPTIONS), null);
This.append (Resources.getString (
Resources.ID_GAME_HIGHSCORES), null);
This.append (Resources.getString (
Resources.ID_GAME_INSTRUCTIONS), null);
This.append (Resources.getString (Resources.ID_GAME_ABOUT), null);
This.append (Resources.getString (Resources.ID_GAME_EXIT), null);
)
)
Public void commandAction (Command p0, Displayable p1) (
List lis = (List) p1;
String selected =
Lis.getString (lis.getSelectedIndex ());
If (selected.equals (Resources.getString (Resources.ID_GAME_NEW))) (
Game = new GameFullCanvas (parent, this);
Parent.setDisplayable (game);
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_OPTIONS))) (
Parent.setDisplayable (
New OptionList (Resources.getString (Resources.ID_GAME_OPTIONS)
List.IMPLICIT,
Parent, and this));
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_HIGHSCORES))) (
Parent.setDisplayable (new HighScore (parent, and this));
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_INSTRUCTIONS))) (
Parent.setDisplayable (
New Instructions (
Resources.getString (Resources.ID_GAME_INSTRUCTIONS), the parent, and this));
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_ABOUT))) (
Parent.setDisplayable (
New About (
Resources.getString (Resources.ID_GAME_ABOUT)
Parent,
This));
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_EXIT))) (
Parent.notifyDestroyed ();
)
Else if (selected.equals (
Resources.getString (Resources.ID_GAME_CONTINUE))) (
If (game! = Null) (
Game.gameContinue ();
Parent.setDisplayable (game);
)
)
)
)
3 game screen
If the user from the main menu, select "New game", then start the game and show that the game screen. Use full-screen canvas screen games (FullCanvas). If you press any button, the user interface must return to the main menu, and the game should be suspended. Other keys to the game is effective. Note: game on the screen should not create any function key label. If labels must use the button, the application should use the default screen Canvas Commands. Sample code does not address issues such as threads and threads security, and other issues, these issues must be in the design of extra attention. The following code is the framework of the game screen.
Import javax.microedition.lcdui .*;
Import com.nokia.mid.ui .*;
Public class GameFullCanvas extends FullCanvas (
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Private boolean gamePaused = false;
Public GameFullCanvas (GameMIDlet parent, MainMenu menu) (
This.parent = parent;
This.menu = menu;
)
Protected void paint (Graphics g) (
/ / Paint the game screen here
)
Protected void keyPressed (int keyCode) (
If (keyCode KEY_SOFTKEY1 == | | == KEY_SOFTKEY2 keyCode
| | == KeyCode KEY_SOFTKEY3) (
GamePaused = true;
/ / Main menu to the screen
Menu.init (parent);
Parent.setDisplayable (menu);
)
)
Public void gameContinue () (
GamePaused = false;
)
Public boolean isPaused () (
Return gamePaused;
)
)
4 game options screen
Users can choose main menu "Options" option to change certain options of the game. Options list is inherent in the list contains entries dealing with the game settings, such as: voice, vibration (see 1, 8), the pitch and so on. To return to the main menu, the need to use Back orders. Options Below is the list of code framework.
Note: If the game is installed to the Games menu, do not need lights / sounds set entries, because those options has been provided by the Games menu.
Import javax.microedition.lcdui .*;
Public class OptionList extends List implements CommandListener (
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Private KeyDefinitions def = null;
Private Command back = new Command ( "", Command.BACK, 2);
Public OptionList (String p0, int p1, p2 String [], [] p3 Image,
GameMIDlet parent, MainMenu menu) (
Super (p0, p1, p2, and p3);
This.menu = menu;
Init (parent);
)
Public OptionList (String p0, int p1, GameMIDlet parent,
MainMenu menu) (
Super (p0, p1);
This.menu = menu;
Init (parent);
)
Private void init (GameMIDlet parent) (
This.parent = parent;
This.addCommand (back);
This.setCommandListener (this);
/ / These are just a examples for the game specific options
This.append (Resources.getString (Resources.ID_GAME_LEVEL)
Null);
This.append (Resources.getString (Resources.ID_GAME_SOUNDS)
Null);
This.append (Resources.getString (Resources.ID_GAME_VIBRA)
Null);
)
Public void commandAction (Command p0, Displayable p1) (
If (p0 == back) (
Parent.setDisplayable (menu);
)
Else (
List lis = (List) p1;
Int idx = lis.getSelectedIndex ();
Switch (idx) (
Case 0:
/ / TODO
Break;
Case 1:
/ / TODO
Break;
Case 2:
/ / TODO
Break;
Case 3:
Parent.setDisplayable (def);
Break;
/ / More if needed
Default:
Break;
)
)
)
)
5 high screen
When the user from the main menu, select "High scores" option when the score will be displayed. Score is displayed in full-screen canvas (FullCanvas) on the case. Score one should be displayed on the screen End, and not scroll pages, users because it will cause trouble.
Of course, high screen may also contain pictures or animations. Users should be able to press through the left button, and the right button, or the number keys Send button to go back to the main menu. This example does not provide any mechanism for dealing with high marks. Two typical high processing methods through the use of records management services (RMS), or through the permanent preservation Score HTTP to connect to the server in the high preservation. The following code is high framework.
Import javax.microedition.lcdui .*;
Import com.nokia.mid.ui .*;
Public class HighScore extends FullCanvas (
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Public HighScore (GameMIDlet parent, MainMenu menu) (
This.parent = parent;
This.menu = menu;
)
Protected void paint (Graphics g) (
/ / Paint the high scores here
)
Public void keyPressed (int keyCode) (
If (keyCode! = KEY_END) (
/ / Selection list to the screen
Parent.setDisplayable (menu);
)
)
)
6 Teaching screen
When the user from the main menu, select the "Instructions" entries, will show the rules of the game. Placed in the text of the rules of the game in the Form examples. Form should be included into the next one for teaching the rules of order (for example, the label "More") and the order to return to the main menu (for example, labels "Back"). "More" from left button control, and "Back" from the right button control. If the rule contains teaching animation, then these should be used full-screen animation canvas (FullCanvas) to display. Press the left button will skip a teaching animation to the next screen. Press the right button, the user will return to the main menu animation. End keys will end applications. Below is the text of the code of rules and teaching animation framework.
/ / Text instructions. Text can be written in constructor or in own
Method.
/ / Developer should remember that also instruction texts should be
/ / Internationalized
Import javax.microedition.lcdui .*;
Public class Instructions extends Form implements CommandListener (
/ / Command for going next instruction if needed
Private Command more = new Command (
Resources.getString (Resources.ID_GAME_MORE)
Command.OK, 1);
/ / Command for going back to the main menu
Private Command back = new Command ( "", Command.BACK, 2);
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Public Instructions (String title, GameMIDlet parent, MainMenu
Menu) (
Super (title);
This.parent = parent;
This.menu = menu;
This.addCommand (back);
This.addCommand (more);
This.setCommandListener (this);
)
Public void commandAction (Command p0, Displayable p1) (
If (p0 == more) (
/ / Go to the next if needed eg animation
Parent.setDisplayable (new InstructionAnimation (parent));
)
Else if (p0 == back) (
Parent.setDisplayable (menu);
)
)
)
/ / Instruction animation
Import javax.microedition.lcdui .*;
Import com.nokia.mid.ui .*;
Public class InstructionAnimation extends FullCanvas (
Private GameMIDlet parent = null;
Public InstructionAnimation (GameMIDlet parent) (
This.parent = parent;
)
Protected void paint (Graphics g) (
/ / Do the animation here
)
Public void keyPressed (int keyCode) (
If (keyCode == KEY_SOFTKEY1) (
/ / Go to the next instruction screen if needed
)
Else if (keyCode == KEY_SOFTKEY2) (
/ / Selection list to the screen
Parent.setDisplayable (new MainMenu (
Resources.getString (
Resources.ID_GAME_NAME)
List.IMPLICIT, parent));
)
)
)
About 7 (About) screen
On (About) screen game production company news text and logos. When the user from the main menu, select the "About" option, the screen will be activated. And teaching the rules of the same pages, pages on the screen if need only text messages, then it can be used to achieve Form. If you need an image or animation, then they should use the Canvas or FullCanvas.
/ / Text "About" code skeleton
Import javax.microedition.lcdui .*;
Public class About extends Form implements CommandListener (
/ / Command for going back to the main menu
Private Command back = new Command ( "", Command.BACK, 1);
Private GameMIDlet parent = null;
Private MainMenu menu = null;
Public About (String title, GameMIDlet parent, MainMenu menu) (
Super (title);
This.parent = parent;
This.menu = menu;
This.addCommand (back);
This.setCommandListener (this);
)
Public void commandAction (Command p0, Displayable p1) (
If (p0 == back) (
Parent.setDisplayable (menu);
)
)
)
8 out
From the main menu, select "Exit game" option to suspend the game and the release of all resources.
Class 9 Resources
Resources category is not a user interface category, introduced in this paper with other different types. This class dealing with international issues.
/ **
* A simple class to simulate a resource bundle.
* Modify the contents of this class according to the
* Locales / languages you want your application to support.
* In your application, retrieve a string using code such as the
* Following:
*
* String s = Resources.getString (Resources.ID_GAME_NEW); *
* Copyright (C) 2002 Nokia Corporation
* /
(Public class Resources
/ / Identifiers for text strings.
Public static final int ID_GAME_NEW = 0;
Public static final int ID_GAME_OPTIONS = 1;
Public static final int ID_GAME_HIGHSCORES = 2;
Public static final int ID_GAME_INSTRUCTIONS = 3;
Public static final int ID_GAME_ABOUT = 4;
Public static final int ID_GAME_CONTINUE = 5;
Public static final int ID_GAME_BACK = 6;
Public static final int ID_GAME_MORE = 7;
Public static final int ID_GAME_EXIT = 8;
Public static final int ID_GAME_LEVEL = 9;
Public static final int ID_GAME_SOUNDS = 10;
Public static final int ID_GAME_VIBRA = 11;
Public static final int ID_GAME_NAME = 12;
/ / List of supported locales.
/ / The strings are Nokia-specific values
/ / Of the "microedition.locale" system property.
Private static final String [] = (supportedLocales
"En", "fi-FI", "fr" and "de"
);
/ / NOTE: default language must be the first one
/ / For getString to work!
/ / Strings for each locale, indexed according to the
/ / Contents of supportedLocales
Private static final String [] [] = (strings
( "New game", "Settings", "High scores," "Instructions"
"About", "Continue", "Back", "More" and "Exit game."
"Level", "Sounds", "Shakes", "Game name"),
( "Uusi peli", "Asetukset", "Huipputulokset", "Peliohjeet"
"Tietoja", "Jatka", "Poistu", "Jatka", "Poistu"
"Vaikeusaste", "Peli? Net," and "V? Rin? Tehosteet"
"Pelin nimi"),
( "Nouveau jeu," "Paramètres" and "Scores", "Instructions"
"A propos," "Continuer", "Retour," "Suite," "Sortir"
"Niveau," "Sons" and "Vibrations," "Jeu nom"),
( "Neues Spiel," "Einstellungen", "Rekord", "Anleitung"
"Über", "Weiter", "Zurück", "Weiter", "Beenden"
"Ebene," "Ton," "Vibrationen", "Spiel name")
);
/ **
* Gets a string for the given key.
* @ Param key Integer key for string
* @ Return The string
* /
Public static String getString (int key) (
String locale = System.getProperty ( "microedition.locale");
If (locale == null) (
Locale = new String (""); / / use empty instead of null
)
/ / Find the index of the locale id
Int localeIndex = -1;
For (int i = 0; i <supportedLocales.length; i + +) (
If (locale.equals (supportedLocales [i])) (
LocaleIndex = i;
Break;
)
)
/ / Not found
If (localeIndex == -1) (
/ / Defaults to first language, in this example English
Return strings [0] [key];
)
Return strings [localeIndex] [key];
)
)
2006-11-26 08:48 PM
↑ Back
Tags: java game, mobile java






