explosion.java

来自「java 写的飞行射击游戏。是游戏的基础。可以参考一下。对游戏开发有帮助。」· Java 代码 · 共 59 行

JAVA
59
字号
package airplane;

import java.awt.Image;
import java.applet.Applet;
import java.awt.Graphics;

public class Explosion{
  private Applet Game;
  private Image[] explFrameImage;
  private int explNum = 0;  //爆炸图片的当前帧
  private int curX, curY;
  private boolean visible;

  public Explosion(Image[] explImages,Applet Game) {
    this.Game = Game;
    explFrameImage = explImages;
   // for(int i=0; i<explFrameImage.length ;i++){
   //   System.out.println(explFrameImage[i]);
   // }
    this.setVisible(false);
    curX = 0;
    curY = 0;
  }

  public void setVisible(boolean v) {
    visible = v;
  }

  public void updateState() { //更新爆炸的帧
    explNum = explNum +1;
    if(explNum >= explFrameImage.length -1){
      explNum = 0;
      this.setVisible(false);
    }
  }

  public void setLocation(int X, int Y) {
    curX = X;
    curY = Y;
  }

  public void paintSprite(Graphics g){

    if (visible == true) {
      //try{
        System.out.println(explNum);
        System.out.println("explFrameImage[explNum]:"+explFrameImage[explNum]);
        System.out.println("curX:"+curX+"  curY:"+curY);
        System.out.println(Game);
        System.out.println(g);
        g.drawImage(explFrameImage[explNum], curX, curY,34,33,Game);
      //}catch(Exception e){}
    }
  }



}

⌨️ 快捷键说明

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