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

📄 layer.java

📁 j2me手机游戏摩迦历险记源代码
💻 JAVA
字号:


import javax.microedition.lcdui.Graphics;

public abstract class layer
{

    int x;
    int y;
    int width;
    int height;
    boolean visible; //可见

    layer(int width, int height)
    {
        visible = true;
        setWidth(width);
        setHeight(height);
    }

    public void setPosition(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public void move(int dx, int dy)
    {
        x += dx;
        y += dy;
    }

    public final int getX()
    {
        return x;
    }

    public final int getY()
    {
        return y;
    }

    public final int getWidth()
    {
        return width;
    }

    public final int getHeight()
    {
        return height;
    }

    public void setVisible(boolean visible)
    {
        this.visible = visible;
    }

    public final boolean isVisible()
    {
        return visible;
    }

    public abstract void paint(Graphics g);

    void setWidth(int width)
    {
        if(width < 0)
        {
            throw new IllegalArgumentException();
        } else
        {
            this.width = width;
            return;
        }
    }

    void setHeight(int height)
    {
        if(height < 0)
        {
            throw new IllegalArgumentException();
        } else
        {
            this.height = height;
            return;
        }
    }
}

⌨️ 快捷键说明

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