?? npc.java
字號(hào):
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
public class Npc extends Sprite implements Runnable{
String name; //人物姓名或道具名稱
String message1; //對(duì)話1
String message2; //對(duì)話2
int npcx; //人物或道具在地圖上的X坐標(biāo)
int npcy; //人物或道具在地圖上的Y坐標(biāo)
// int isren; //是人物還是道具,1是人物,0是道具
// boolean addbool=false; //判斷是否添加特殊道具
Image img;
boolean pause = false;
int step = 1;
int directionLeft = 4 , directionRight = 8;
int temp = 0 , counter = directionRight;
public Npc(Image arg0, int width, int height, String myname,
String mymessage1, int x, int y, String mymessage2, Image imagetemp) {
super(arg0, width, height);
name = myname;
message1 = mymessage1;
npcx = x;
npcy = y;
message2 = mymessage2;
img = imagetemp;
this.setPosition(npcx, npcy);
}
public Npc(Image img, int x, int y) {
super(img, x, y);
}
public void run() {
while(true){
if(!pause){
this.setFrame(counter + temp);
temp ++;
if(temp == 4) temp = 0;
npcx += step;
this.setPosition(npcx, npcy);
if(npcx >= 220){
npcx = 220;
counter = directionLeft;
temp = 0;
step = -step;
}
if(npcx <= 120){
npcx = 120;
counter = directionRight;
temp = 0;
step = -step;
}
}
try {
Thread.sleep(150);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -