有了子弹,子弹想有个飞机能发射子弹了。好,现在我们就实现玩家的战机
/// <summary>
/// Description of GamePlayer.
/// </summary>
public class GamePlayer : GameObject
{
private GameScene mScene = null;
private Vector2 InitPosition;
public Vector2 Speed;
public bool IsLive;
private float ShootDelay = 0;
private float ShootDelayTime = 0;
private int PlayerSpriteIndex;
private int Life = 0; // 生命值
private float ReliveTime = 0; // 重生时间
private float GodTime = 0; // 无敌时间
}
这是玩家类的定义,当然也是继承自GameObject的。
我们可以看到,玩家类定义的东西比GameBullet明显多了一点。但大体上差不多的。
然后是具体的实例化和一些基本函数
public GamePlayer(GameScene scene, Vector2 position, Vector2 speed)
{
this.mScene = scene;
this.InitPosition = position;
this.Position = position;
this.Speed = speed;
this.BoxC