📄 sprite.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
// Source File Name: Sprite.java
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Sprite
{
private Image image;
private int x;
private int y;
private int width;
private int height;
private int numFrames;
private int frame;
private boolean visible;
public Sprite(Image image, int width, int height, int numFrames)
throws Exception
{
visible = true;
this.image = image;
this.width = width;
this.height = height;
this.numFrames = numFrames;
if(image.getHeight() != height)
throw new Exception("Height not correct: " + height + " must be: " + image.getHeight());
if(image.getWidth() / numFrames != width)
throw new Exception("Width not correct:" + width + " must be: " + image.getWidth());
else
return;
}
public void paint(Graphics g)
{
if(visible)
{
g.setClip(x, y, width, height);
g.drawImage(image, x - frame * width, y, 20);
g.setClip(0, 0, 176, 208);
}
}
public int getX()
{
return x;
}
public void setX(int x)
{
this.x = x;
}
public int getY()
{
return y;
}
public void setY(int y)
{
this.y = y;
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public int getFrame()
{
return frame;
}
public void setFrame(int frame)
throws Exception
{
if(frame < 0 || frame > numFrames - 1)
{
throw new Exception("Not correct frame number:" + frame + "-" + numFrames);
} else
{
this.frame = frame;
return;
}
}
public void setVisible(boolean visible)
{
this.visible = visible;
}
public int getNumFrames()
{
return numFrames;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -