📄 splashscreen.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public final class SplashScreen extends Canvas implements Runnable,CommandListener {
private Puke midlet;
private Sprite ordeR,ordeL;
private Image splashLogo1,splashLogo2,voice,im_orde;
private int Count=3,sX1,sX2;
private boolean Pause=false,Stop=false,Over=false,Flash=false;
public SplashScreen(Puke midlet ) throws Exception {
this.midlet = midlet;
setFullScreenMode(true);
sX1=0;
sX2=getWidth();
try {
splashLogo1 = Image.createImage("/splash1.png");
splashLogo2 = Image.createImage("/splash2.png");
voice = Image.createImage("/voice.png");
im_orde = Image.createImage("/orde.png");
} catch(Exception ex) {}
ordeR = new Sprite (im_orde,23,11);
ordeR.setPosition(1,208);
ordeR.setFrame(0);
ordeL = new Sprite (im_orde,23,11);
ordeL.setPosition(152,208);
ordeL.setFrame(1);
startThread();
setCommandListener(this);
}
private void startThread(){
Pause=false;
Thread th=new Thread(this);
th.start();
}
public void commandAction(Command c, Displayable d) {
}
public void keyPressed(int keyCode){
{
switch(keyCode){//三页显示
case -5:
if(Stop){
Stop=false;
sX1=101;
}
if(sX1==177){
midlet.playMusic=true;
midlet.mainMenuScreenShow();
}
break;
case -7://有
if(sX1==177){
Pause=true;
midlet.playMusic=true;
midlet.mainMenuScreenShow();
}
break;
case -6://无
if(sX1==177){
Pause=true;
midlet.playMusic=false;
midlet.mainMenuScreenShow();
}
break;
}
}
}
public void run(){
while(!Pause){
if(!Stop){
sX1+=5;
sX2-=5;
}
if(sX1==100){
Stop=true;
Flash=!Flash;
try{Thread.sleep(50);
}catch (Exception e){}
}
if(sX1>176)
{
sX1=177;
Over=true;
}
if(sX1==177){
Flash=!Flash;
try{Thread.sleep(50);
}catch (Exception e){}
}
try{Thread.sleep(20);
}catch (Exception e){}
repaint();
}
}
protected void paint(Graphics g) {
g.setColor(0x00000000);
g.fillRect(0, 0, getWidth(), getHeight());
if(!Over){
g.drawImage(splashLogo2,sX2,getHeight()/2-15,Graphics.VCENTER|Graphics.HCENTER);
g.drawImage(splashLogo1,sX1,getHeight()/2+15,Graphics.VCENTER|Graphics.HCENTER);
}
if(Flash){
g.setColor(0x00ff00);
g.fillTriangle(84, 210, 92, 210, 88, 214);
}
if(Over){
g.drawImage(voice,getWidth()/2,getHeight()/2,Graphics.VCENTER|Graphics.HCENTER);
ordeR.paint(g);
ordeL.paint(g);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -