?? sprite.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 + -