www.pudn.com > TWPlaneGame.rar > EnemyPlane.java


package twplanegame; 
 
import javax.microedition.lcdui.*; 
 
class EnemyPlane 
    extends PlaneGameObject 
{ 
    private int XSpeed = LSpeed; //Speed 
    private int YSpeed = LSpeed; // 
    private int Direct = UP; // 方向 up 0;right 1;down 2;left 3 
    private int FlyType = 0; // 飞行轨迹 0 直线; 1 抛物线 ;2 S形 
 
    //constructor 
    public EnemyPlane() 
    { 
        super(1, 0, 0); 
        try { 
            ObjImage = Image.createImage("/e_plane0.PNG"); 
        } 
        catch (Exception e) { 
            ObjImage = null; 
        } 
        int width = ObjImage.getWidth(); 
        int height = ObjImage.getHeight(); 
        int radius = width < height ? width : height; 
        SetImageSize(width, height, radius); 
    } 
 
    public void SetValue(int id) //set charactor values for enemy plane 
    { 
        SetID(id); 
        SetState(ALIVE); 
        switch (id) { 
            case 1: //enimy plane type 1 
                SetHP(1); 
                SetSpeed(LSpeed, LSpeed); 
                FlyType = 1; 
                break; 
            case 2: //enimy plane type 2 
                SetHP(1); 
                SetSpeed(LSpeed, LSpeed); 
                FlyType = 2; 
                break; 
            case 3: //enimy plane type 3 
                SetHP(1); 
                SetSpeed(LSpeed, LSpeed); 
                FlyType = 3; 
                break; 
        } 
    } 
 
    public int getXSpeed() 
    { 
        return XSpeed; 
    } 
 
    public int getYSpeed() 
    { 
        return YSpeed; 
    } 
 
    public void SetSpeed(int xs, int ys) 
    { 
        XSpeed = xs; 
        YSpeed = ys; 
    } 
 
    public int getDirect() 
    { 
        return Direct; 
    } 
 
    public int getFlyType() 
    { 
        return FlyType; 
    } 
 
    public int SetFlyType(int t) 
    { 
        return FlyType = t; 
    } 
 
}