npc.java

来自「手机RPG游戏」· Java 代码 · 共 39 行

JAVA
39
字号
package obj;
import main.*;
import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
public class Npc extends Sprite{
  private int direct=0;
  private int xpos;
  private int ypos;
  private int s=MyControl.load.npcSpeed;//npc的移动速度
  public boolean isSpeaking=false;

  private static final int[] k = {0, 1, 2, 3, 4, 5, 6, 7};

  public void turn(int d,int sx,int sy){
     if(!isSpeaking){
          if((direct==k.length>>1)||(direct==0)){s=-s;}
          direct=(direct+d)%k.length;
          this.setFrame(k[direct]);
          xpos+=sx*s;
          ypos+=sy*s;}
    else{this.setFrame(0);}
    this.setPosition(xpos,ypos);

  }
  public Npc(Image img,int width,int height,int x,int y) {
    super(img,width,height);
    xpos=x;
    ypos=y;
    this.setPosition(xpos,ypos);
  }
  public int getXpos() {
    return xpos;
  }
  public int getYpos() {
    return ypos;
  }


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?