日期:2014-05-20  浏览次数:20856 次

J2me小特效:会动的波浪字体
J2me小特效:会动的波浪字体



import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class DrawCanvas extends MIDlet implements CommandListener {
private Command exitCommand;
private HCanvas sg;
public DrawCanvas() {
exitCommand = new Command("Exit", Command.EXIT, 1);
sg = new HCanvas();
sg.addCommand(exitCommand);
sg.setCommandListener(this);
Display.getDisplay(this).setCurrent(sg);

}
protected void startApp(){
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0){
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
class HCanvas extends Canvas implements Runnable{

private String str=new String("PRESS 5");
private int[] ak={0,0,0,0,0,0,0,1,2,3,3,2,1,0,0,0,0,0,0,0};
boolean kaishi=true;
private int k=6;

public HCanvas (){
new Thread(this).start();
}

protected void paint(Graphics g){
g.setColor(0x00ffffff);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(0x00000000);
for(int i=0;i< str.length();i++){
g.drawString(str.substring(i,i+1),20+i*7,10-ak[k-i],0);
g.drawString(str.substring(i,i+1),21+i*7,11-ak[k-i],0);//加重字体7是字体宽度
}
}
public void run(){
while(kaishi){
try {
repaint(); //再描绘
Thread.sleep(70); //等待一定时间
k++;
if(k>(ak.length-1)) k=6;
}
catch(InterruptedException e){}
}
}
}
1 楼 pandonix 2007-08-28  
楼主有没有试过,实现像很多jsp网页中的水中倒影的效果?rovio推出一款,叫war diary:torpedo的潜艇游戏,在开机画面中的波浪效果做的非常逼直,有兴趣可以下载来看看。这些都应该属于粒子系统的应用,以前,受限于j2me平台的运算能力,但是现在实现起来,也并非不可能,如果做得好,效果依然很好。
2 楼 wuhua 2007-08-29  
看来楼主也是j2me高手哦。能加个朋友否,楼主对j2me游戏应该比较有了解吧
3 楼 pandonix 2007-08-29  
可以啊,我的资料里面有我的联系方式:)