Auxiliary BACKDROP class
Package npc7776;
Import javax.microedition.lcdui. *;
/ *************************************************
* Class features: Set background and clear screen
*************************************** /
Public class backdrop {
Image IMG;
Int width, Height;
Public Backdrop (int width, int hotht) {
THIS.WIDTH = Width;
THISHEIGHT = HEIGHT;
Try {
IMG = image.createImage ("/ res / backdrop.png");
}
Catch (Exception E) {}
}
Public void Dramslef (Graphics G) {
G.drawImage (IMG, Width / 3, Height / 3, Graphics.top | Graphics.Left);
}
}
This class is relatively simple, declared the background diagram, load the specified graphics in the constructor, pay attention to the suffix
The name is PNG. When the IMG is constructed, I remember to have an exception. Image.createImage () is through
The resource file loads the PNG image (CreateImage has many other ways). Use Graphics to lose
The way to call when the image is: VoidDrawImage (Image, Int X, Int Y, Int Anchor)
Here is just a simple background, of course, a game will not be as simple, other methods, etc.
After writing this, you will slowly introduce.
Auxiliary ABOUT
Package npc7776;
Import javax.microedition.lcdui. *;
Public Class About Extends Form Immandlistener {
Private command cmdback = NULL;
Private Planemain MAINSCREEN = NULL;
Public About (Planemain M) {
Super ("About");
MAINSCREEN = M;
CMDBACK = New Command ("Return", Command.back, 1);
This.Addcommand (cmdback);
This.SetCommandListener (this);
THIS.APPpend ("Developer");
this.Append ("Write the name");
}
Public void CommandAction (Command C, Displayable D) {
IF (c == cmdback) {
MAINSCREEN.GOBACK ();
}
}
}
A program explains the author information, version information, copyright information, etc. of this program when the release is completed.
The author wants an instruction show. This class is to do this. It is independent of a window.
And realize the monitor interface, can transfer to the initiated page. It should be noted that he inherited the FORM class. here
THIS.APpend ("Developer") and this.append ("Write Name") Add a text title to
The final end of the Form object returns the location of the added object. Equivalent to calling Append (New
StringItem (NULL, STR)) is just a simple application of the FORM class.
There are also three important classes without writing, and you can do it in the near future. If there is anything wrong with
Please ask, there is anything you don't understand, I will try my best, thank you Mingjava.
I have to give up, I try to organize them together. Or wait for me to finish them in 2-3 levels. This game is uploaded here. Ways in jb package wizards ->
Archive Builder ---> Join the picture -> Project window will appear MIDlet Suite, this
You can run it. Sometimes Midlet Suite is 0 bytes, point to MIDlet Suite Right-click
Make.
Click to browse this file
Please put it in the / res directory of the established project.