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

📄 sprite.java

📁 太空大战J2ME版本
💻 JAVA
字号:
package game0925;

import javax.microedition.lcdui.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public abstract class Sprite {
    protected int x;
    protected int y;
    protected int width;
    protected int height;
    protected boolean isAlive;
    protected boolean isHit;
    public Sprite() {
    }

    void setX(int x) {
        this.x = x;
    }

    int getX() {
        return x;
    }

    void setY(int y) {
        this.y = y;
    }

    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;
    }

    boolean isHit() {
        return isHit;
    }

    boolean isOver(Sprite other) { //是否重复
        if (other.getX() <= x && other.getX() + other.getWidth() >= x ||
            other.getX() >= x && other.getX() <= x + width) {
            if (other.getY() <= y && other.getY() + other.getHeight() >= y ||
                other.getY() >= y && other.getY() <= y + height) {
                return true;
            }
        }
        return false;
    }

    abstract void doMove();

    abstract void paint(Graphics g);

}

⌨️ 快捷键说明

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