Implement the welcome interface (with source code) in j2_m3)

Source: Internet
Author: User

In the compiling process of the j2_game, it is common to make a welcome interface. The following describes how to make a welcome interface.
There are two methods to implement the welcome interface:
1. Press any key to enter the main interface of the system.
2. Wait n seconds (n <6) before entering the main interface
The implementation code is as follows:
// Press any key to enter the main interface
Import javax. microedition. lcdui .*;
Public class WelcomeCanvas extends Canvas {
// Background image
Image bgImage = null;
Display display;
Public WelcomeCanvas (Display display ){
This. display = display;
// Import the image
Try {
BgImage = Image. createImage ("/res/welcome.png ");
} Catch (Exception e ){
Alert a = new Alert ("error", "The resource file does not exist! ", Null, AlertType. ERROR );
A. setTimeout (Alert. FOREVER );
// Display the prompt box
Display. setCurrent ();
}
}
Protected void paint (Graphics g ){
// Draw a background image
G. drawImage (bgImage, 0, 0, Graphics. TOP | Graphics. LEFT );
}
Protected void keyPressed (int keyCode ){
// Display the interface to be displayed
Display. setCurrent (new MainList ());
}
}
// Automatically enters the main interface five seconds later
Import javax. microedition. lcdui .*;
Public class WelcomeCanvas extends Canvas implements Runnable {
// Background image
Image bgImage = null;
Display display;
Public WelcomeCanvas (Display display ){
This. display = display;
// Import the image
Try {
BgImage = Image. createImage ("/res/welcome.png ");
} Catch (Exception e ){
Alert a = new Alert ("error", "The resource file does not exist! ", Null, AlertType. ERROR );

Related Article

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.