📄 animation.java
字号:
package Game;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
public class animation implements Runnable{
Image offI;
public Image[] imgAnimation=new Image[110];
Graphics offG;
int WIDTH;
int HEIGHT;
Container c;
animation(Container c)
{
this.c=c;
for(int i=1;i<=109;i++)
imgAnimation[i]=(new ImageIcon("pic/Animation/"+i+".jpg")).getImage();
WIDTH=imgAnimation[50].getWidth(null);
HEIGHT=imgAnimation[50].getHeight(null);
offI=c.createImage(c.getWidth(),c.getHeight());
offG=offI.getGraphics();
new Thread(this).start();
}
public void showPicture()
{
for(int i=1;i<=109;i++)
{
offG.drawImage(imgAnimation[i], 0, 0, null);
try {
Thread.sleep(80);
} catch (InterruptedException e) {
e.printStackTrace();
}
update();
}
}
public void update(){
c.getGraphics().drawImage(offI,0,0,null);
}
public void run() {
while(true)
{
update();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -