import java.awt.Graphics; import java.awt.Image; import java.awt.Toolkit; public class BombTank { private int x, y; private boolean live = true; // 初始状态为活着的 private TankClient tc; private static Toolkit tk = Toolkit.getDefaultToolkit(); private static Image[] imgs = { // 存储爆炸图片 从小到大的爆炸效果图 tk.getImage(BombTank.class.getClassLoader().getResource( "images/1.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/2.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/3.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/4.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/5.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/6.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/7.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/8.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/9.gif")), tk.getImage(BombTank.class.getClassLoader().getResource( "images/10.gif")), }; int step = 0; public BombTank(int x, int y, TankClient tc) { // 构造函数 this.x = x; this.y = y; this.tc = tc; } public void draw(Graphics g) { // 画出爆炸图像 if (!live) { // 坦克消失后删除爆炸图 tc.bombTanks.remove(this); return; } if (step == imgs.length) { live = false; step = 0; return; } g.drawImage(imgs[step], x, y, null); step++; } }
最近下载更多
krispeng LV7
4月16日
lwl1207 LV4
2023年8月29日
aa12356 LV1
2023年3月26日
hkxyyz LV6
2023年3月2日
3043864991 LV2
2023年1月5日
jameshkj LV8
2023年1月1日
冰锋之泪 LV7
2023年1月1日
337110415 LV7
2022年10月24日
2483935277 LV3
2022年9月3日
微信网友_5926336788320256 LV6
2022年5月24日