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

📄 sprite.java

📁 一款基于j2me技术的手机版游戏——飞机射击
💻 JAVA
字号:

import javax.microedition.lcdui.*;
abstract class Sprite {
  protected  int x;
  protected  int y;
  protected  int width;
  protected  int height;
  protected  boolean isAlive=true;
  protected  boolean isHit  =false;
  protected  int tickCount  = 0;
  void setX(int x){
    this.x=x;
  }
  void setY(int y){
   this.y=y;
 }
int getX(){
  return x ;
}
int getY(){
  return y ;
}
int getwidth(){
  return width ;
}
int getheight(){
  return height ;
}
void setAlive(boolean isAlive){
  this.isAlive = isAlive ;
}
boolean isAlive(){
  return isAlive;
}
void setHit(boolean isHit){
  this.isHit = isHit ;
  tickCount = 0;
}
boolean isHit(){
  return isHit;
}
boolean isOverlaps(Sprite otherSprite){
  if( (otherSprite.getX()<=x &&
      otherSprite.getX()+otherSprite.getwidth()>=x) ||
      (otherSprite.getX()>=x &&
       otherSprite.getX()<= x+width) ){
    if( (otherSprite.getY()<= y && otherSprite.getY() + otherSprite.getheight()>=y)
        || (otherSprite.getY()>=y && otherSprite.getY()<= y+height)){
      return true ;
    }
  }
  return false;
}
  abstract void doMove();
  abstract void doDraw(Graphics g);
}

⌨️ 快捷键说明

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