⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 npc.java

📁 手机RPG游戏
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -