sprite.java

来自「j2me源代码」· Java 代码 · 共 52 行

JAVA
52
字号
package pinball;import javax.microedition.lcdui.Graphics;public class Sprite {    public int x;    public int y;    public int width;    public int height;    public int shadow;    public Sprite() {        shadow = Math.max(2, Screen.width / 60);    }    public int getCenterX() {        return x + width / 2;    }    public int getCenterY() {        return y + height / 2;    }    public void moveTo(int x, int y) {        this.x = x;        this.y = y;    }    public void moveBy(int x, int y) {        this.x += x;        this.y += y;    }    public void paint(Graphics g) {}    public void paintShadow(Graphics g) {}    public boolean intersects(Sprite other) {        int xw = x + width;        int yh = y + height;        int oxw = other.x + other.width;        int oyh = other.y + other.height;        return x >= other.x && x < oxw && y >= other.y && y < oyh               || xw >= other.x && xw < oxw && y >= other.y && y < oyh               || x >= other.x && x < oxw && yh >= other.y && yh < oyh               || xw >= other.x && xw < oxw && yh >= other.y && yh < oyh;    }}

⌨️ 快捷键说明

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