Java关于飞机大战项目的一个基础问题
本帖最后由 会断 于 2021-5-25 08:26 编辑pause输出为4是什么原因?gif的输出为2是因为代码不对吗,我可能还没学到
package cn.tedu;
import javax.swing.ImageIcon;
public class Images {
public static final ImageIcon[] airplane;
public static final ImageIcon[] bigairplane;
public static final ImageIcon bee;
public static final ImageIcon bullet;
public static final ImageIcon[] hero;
public static final ImageIcon bom;
public static final ImageIcon sky;
public static final ImageIcon start;
public static final ImageIcon pause;
public static final ImageIcon gameover;
static {
airplane = new ImageIcon;
airplane = new ImageIcon("images/airplane0.png");
airplane = new ImageIcon("images/airplane1.png");
bigairplane = new ImageIcon;
bigairplane = new ImageIcon("images/bigairplane0.png");
bigairplane = new ImageIcon("images/bigairplane1.png");
bee = new ImageIcon("images/bee0.gif");
bullet = new ImageIcon("images/bullet.png");
hero = new ImageIcon;
hero = new ImageIcon("images/hero0.png");
hero = new ImageIcon("images/hero1.png");
bom = new ImageIcon("images/bom.gif");
sky = new ImageIcon("images/background.png");
start = new ImageIcon("images/start.png");
pause = new ImageIcon("iamges/pause.png");
gameover = new ImageIcon("images/gameover.png");
}
public static void main(String[] args) {
System.out.println(airplane.getImageLoadStatus());
System.out.println(airplane.getImageLoadStatus());
System.out.println(bigairplane.getImageLoadStatus());
System.out.println(bigairplane.getImageLoadStatus());
System.out.println(bee.getImageLoadStatus());
System.out.println(bullet.getImageLoadStatus());
System.out.println(hero.getImageLoadStatus());
System.out.println(hero.getImageLoadStatus());
System.out.println(bom.getImageLoadStatus());
System.out.println(sky.getImageLoadStatus());
System.out.println(start.getImageLoadStatus());
System.out.println(pause.getImageLoadStatus());
System.out.println(gameover.getImageLoadStatus());
}
}
按住CTRL点一下那个方法,看看源码就知道了啊 你说的是这个吗?详见JDK源码:java.awt.Mediatracker.java
/**
* Flag indicating that media is currently being loaded.
* @see java.awt.MediaTracker#statusAll
* @see java.awt.MediaTracker#statusID
*/
public static final int LOADING = 1;
/**
* Flag indicating that the downloading of media was aborted.
* @see java.awt.MediaTracker#statusAll
* @see java.awt.MediaTracker#statusID
*/
public static final int ABORTED = 2;
/**
* Flag indicating that the downloading of media encountered
* an error.
* @see java.awt.MediaTracker#statusAll
* @see java.awt.MediaTracker#statusID
*/
public static final int ERRORED = 4;
/**
* Flag indicating that the downloading of media was completed
* successfully.
* @see java.awt.MediaTracker#statusAll
* @see java.awt.MediaTracker#statusID
*/
public static final int COMPLETE = 8; VioletKiss 发表于 2021-5-24 09:47
你说的是这个吗?详见JDK源码:java.awt.Mediatracker.java
/**
不是..不过以解决了
页:
[1]