Here is my ship class code:
package{
import flash.display.Sprite;
import flash.display.Graphics;
import flash.text.TextField;
import flash.display.MovieClip;
public class Enemy extends MovieClip{
private var health_txt:TextField;
private var health:int;
private var speed_x:Number;
private var speed_y:Number;
private var scale_x:Number;
private var scale_y:Number;
public function Enemy() {
health = 2;
speed_x = -1.5;
speed_y = 0;
addGalleon();
draw();
}
private function addGalleon():void{
var newShip:testShip = new testShip();
this.addChild(newShip);
}
private function draw():void {
health_txt = new TextField();
health_txt.height = 20; health_txt.width = 15;
health_txt.textColor = 0xffffff;
health_txt.x = 40;
health_txt.y = -40;
health_txt.text = health + "";
addChild(health_txt);
}
public function update():void {
x += speed_x;
y += speed_y;
}
public function updateHealth(amount:int):int {
health += amount;
health_txt.text = health + "";
return health;
}
}
}

New Topic/Question
Reply


MultiQuote


|