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

📄 animate.java

📁 一个j2me游戏开发引擎
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

package mmae.ui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Animate
{

    private Image e;
    private int a;
    private int h;
    private int d;
    private int f;
    private int g[];
    private boolean c;
    private int b;
    public int frameRows;
    public int frameCols;

    private void a(int i, int j)
        throws IllegalArgumentException
    {
        if(i < 1 || j < 1 || e.getWidth() % i != 0 || e.getHeight() % j != 0)
        {
            throw new IllegalArgumentException();
        } else
        {
            frameCols = e.getWidth() / i;
            frameRows = e.getHeight() / j;
            return;
        }
    }

    private void a(Image image)
        throws NullPointerException
    {
        if(image == null)
            throw new NullPointerException();
        if(image.isMutable())
            e = Image.createImage(image);
        else
            e = image;
    }

    public Animate(Image image)
        throws NullPointerException
    {
        a(image);
        frameRows = 1;
        frameCols = 1;
        c = true;
    }

    public Animate(Image image, int i, int j)
        throws NullPointerException, IllegalArgumentException
    {
        a(image);
        a(i, j);
        c = true;
    }

    public Animate(Animate animate)
        throws NullPointerException
    {
        if(animate == null)
            throw new NullPointerException();
        a = animate.a;
        h = animate.h;
        d = animate.d;
        f = animate.f;
        c = animate.c;
        e = animate.e;
        frameRows = animate.frameRows;
        frameCols = animate.frameCols;
        if(animate.g == null)
            g = null;
        else
            g = animate.getFrameSequence();
    }

    public void setPosition(int i, int j)
    {
        a = i;
        h = j;
    }

    public void setDepth(int i)
    {
        d = i;
    }

    public void move(int i, int j)
    {
        a += i;
        h += j;
    }

    public int getX()
    {
        return a;
    }

    public int getY()
    {
        return h;
    }

    public int getDepth()
    {
        return d;
    }

    public int getHeight()
    {
        return e.getHeight() / frameRows;
    }

    public int getWidth()
    {
        return e.getWidth() / frameCols;
    }

    public void setFrame(int i)
        throws ArrayIndexOutOfBoundsException
    {
        if(i < 0 || i >= getFrameSequence().length)
        {
            throw new ArrayIndexOutOfBoundsException();
        } else
        {
            f = i;
            return;
        }
    }

    public int getFrame()
    {
        return f;
    }

    public int getNumRawFrames()
    {
        return frameRows * frameCols;
    }

    public void nextFrame()
    {
        f++;
        if(g == null)
        {
            if(f >= getNumRawFrames())
                f = 0;
        } else
        if(f >= g.length)
            f = 0;
    }

    public void prevFrame()
    {
        if(--f < 0)
            if(g == null)
                f = getNumRawFrames() - 1;
            else
                f = g.length - 1;
    }

    public void setVisible(boolean flag)
    {
        c = flag;
    }

    public boolean isVisible()
    {
        return c;
    }

    public final void draw(Graphics g1)
        throws NullPointerException
    {
        if(g1 == null)
            throw new NullPointerException();
        if(c && e != null)
        {
            int i = g1.getClipX();
            int j = g1.getClipY();
            int k = g1.getClipWidth();
            int l = g1.getClipHeight();
            int i1;
            if(g == null)
                i1 = f;
            else
                i1 = g[f];
            g1.setClip(a, h, getWidth(), getHeight());
            if(b == 0)
            {
                Graphics _tmp = g1;
                Graphics _tmp1 = g1;
                g1.drawImage(e, a - (i1 % frameCols) * getWidth(), h - (i1 / frameCols) * getHeight(), 0x10 | 0x4);
            } else
            {
                Graphics _tmp2 = g1;
                Graphics _tmp3 = g1;
                g1.drawImage(e, a - (i1 / frameRows) * getWidth(), h - (i1 % frameRows) * getHeight(), 0x10 | 0x4);
            }
            g1.setClip(i, j, k, l);
        }
    }

    public void setMode(int i)
    {
        b = i;
    }

    public int getMode()
    {
        return b;
    }

    public void setFrameSequence(int ai[])
        throws ArrayIndexOutOfBoundsException
    {
        if(ai == null)
        {
            g = null;
        } else
        {
            int i = ai.length;
            int j = getNumRawFrames() - 1;
            int ai1[] = new int[ai.length];
            while(i-- > 0) 
            {
                if(ai[i] < 0 || ai[i] > j)
                    throw new ArrayIndexOutOfBoundsException();
                ai1[i] = ai[i];
            }
            g = ai1;
        }
        f = 0;
    }

    public int[] getFrameSequence()
    {
        int ai[];
        if(g == null)
        {
            int i = getNumRawFrames();
            ai = new int[i];
            while(i-- > 0) 
                ai[i] = i;
        } else
        {
            ai = new int[g.length];
            System.arraycopy(g, 0, ai, 0, g.length);
        }
        return ai;
    }

    public void setImage(Image image, int i, int j)
        throws NullPointerException, IllegalArgumentException
    {
        int k = getNumRawFrames();
        a(image);
        a(i, j);
        if(getNumRawFrames() < k)
        {
            f = 0;
            g = null;
        }
    }
}

⌨️ 快捷键说明

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