自己的飞机类,先判断他的isAlive为true和isExplosion为false如果满足再把他进行绘制,以及帧动画,游戏过程中两张图片不停的切换形成动画效果,当死亡是也有一个动
画。
package com.example.qgns;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
public class MyPlane extends GameObject {
private Bitmap myPlane[]=new Bitmap[2];//定义数组图片
private Bitmap myPlaneExplosion[]=new Bitmap[4]; //爆炸数组图片
private float middle_x;//因为子弹的位置与飞机位置有关
private float middle_y;//这两个参数传给子弹的
public MyPlane(Resources res) {
super(res);
isAlive=true;//设为存活状态
initBitmap();
}
@Override
public void initScreen(float screen_width, float screen_height) {//初始化开始位置
super.initScreen(screen_width, screen_height);
object_x=screen_width/2-object_width/2;
object_y=screen_height-object_height*2;
middle_x