J2ME Mobile game Development Diary 1

Source: Internet
Author: User
J2ME Novice, did a game project, some experience, feel that some things can still be taken out and share. Excuse me if I'm wrong.

Development environment:

Windows2000+jbuilder X+semc_j2me_sdk_2_1_4_beta

Never contacted this aspect, because the Group a project to start to learn J2ME, read two days of books, found that the JDK is still very simple. There are a total of those classes. Only if you want to consider the optimal optimization of resources and performance, the algorithm and data structure requirements are relatively high.

First, the setting of the environment:
1, Windows2000 (this needless to say)
2, JBuilder X (other version of the JBuilder in fact, it should be no problem, but I only 512 machine, running 9 or 2005 words a bit depressed)
3, because it is for Sony Ericsson's K700C development project, so JDK using Sony Ericsson's JDK
4, JBuilder Use the mobile phone JDK, the steps for Tools-configure Jdks-add

The development of J2ME words first understand the structure of J2ME, read a lot of introductory document sequence is probably all the same, online this aspect of the introduction of the vast, I do not repeat here, just say my understanding.
The core of J2ME is configuration (CLDC, CDC), which is profile (MIDP), and most of our mobile phone development is in profile, that is to say, CLDC+MIDP.
If you want to learn more about the history of J2ME, you can download the JSR specification to read, address is http://jcp.org

First day of work:
A bit messy, because it is also just contact with this dongdong, a little practical experience is not (Java is just looking at the bits and pieces). Holding a book in the laboratory for a whole day, probably understand the basic structure of the program. (The second edition of "J2ME Wireless Device Program Design", which is highly recommended by Sun, is very enjoyable to see).
Classes that inherit the MIDlet class in the program can be understood as the entry point of the program. Equivalent to the WinMain in Win32, the words are run from this beginning.
The structure of the MIDlet is
public class Gamemidlet extends MIDlet {
Public Gamemidlet () {}//constructor, parameter must be empty
The public void startApp ()//program starts (or goes back to the program after being interrupted by the system)
The public void Pauseapp ()//program pauses (handles some of the paused cleanup, but notice that the system encounters an incoming call or event of this type instead of pausing the program, but the entire suspend, and then starts executing Startapp ())
public void Destroyapp (boolean con)//Destroy work. }

Write so much today, say displayable and graphics tomorrow. Also said about the J2ME mobile phone game structure.

Attached: simple MIDlet
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;

public class Hellomidlet extends MIDlet implements Commandlistener

{

private display display;

Private Command Exitcommand;

private TextBox text;

Public Hellomidlet () {

display = Display.getdisplay (this);

Exitcommand = new Command ("Leave", Command.back, 1);

Text = new TextBox ("Hello App", "welcome!", 256, 0);

Text.addcommand (Exitcommand);

Text.setcommandlistener (this);

}

public void startApp () {

Display.setcurrent (text);

}

public void Pauseapp () {}

public void Destroyapp (Boolean unconditional) {}

public void Commandaction (Command C, displayable s) {

if (c = = Exitcommand) {

Destroyapp (FALSE);

Notifydestroyed ();

}

}






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.