主文件
package{
import flash.display.MovieClip;
import flash.events.*;
public class Main extends MovieClip {
public var _root:MovieClip;
public var monsterContainer:MovieClip = new MovieClip();
public var delay = 30;
public function Main(){
addEventListener(Event.ADDED, beginClass);
addEventListener(Event.ENTER_FRAME, enterFrameEvents);
}
function beginClass(e):void{
_root = MovieClip(root);
}
function enterFrameEvents(e):void{
addChild(monsterContainer);
delay -= 1;
if(delay <= 0){
var spawn:Slime = new Slime();
spawn.x = startPoint.x;
spawn.y = startPoint.y;
monsterContainer.addChild(spawn);
delay = 30;
}
}
}
箭头.as
package{
import flash.display.MovieClip;
import flash.events.*;
public class Arrow extends MovieClip {
public var _root:MovieClip;
public var facingID;
public function Arrow(){
addEventListener(Event.ADDED, beginClass);
addEventListener(Event.ENTER_FRAME, enterFrameEvents);
}
function beginClass(e):void{
_root = MovieClip(root);
}
function enterFrameEvents(e):void{
trace(_root.monsterContainer == null);
}
}
敌人
package{
import flash.display.MovieClip;
import flash.events.*;
public class Enemy extends MovieClip {
public var _root:MovieClip;
//Status
public var monsterSpeed;
public var facing = "Right";
//CallingArrow
public var down:Down = new Down();
public function Enemy(){
addEventListener(Event.ADDED, beginClass);
addEventListener(Event.ENTER_FRAME, enterFrameEvents);
}
function beginClass(e):void{
_root = MovieClip(root);
}
function enterFrameEvents(e):void{
//Facing Movement
if(_root.pausing == false){
if(facing == "Right"){
this.x += monsterSpeed;
}else if(facing == "Left"){
this.x -= monsterSpeed;
}else if(facing == "Down"){
this.y += monsterSpeed;
}else if(facing == "Up"){
this.y -= monsterSpeed;
}
}
}
}
Down.as
package {
import flash.display.MovieClip;
import flash.events.*;
public class Down extends Arrow {
public function Down(){
facingID = "Down";
}
}
史莱姆
package {
import flash.display.MovieClip;
import flash.events.*;
public class Slime extends Enemy {
public function Slime(){
monsterSpeed = 5;
}
}
并且时间轴上没有其他代码,只需 stop();
我收到 1119 错误,当我想访问粘液中的电影剪辑时,我给它怪物作为实例名称,请帮助!
下载链接:http ://www.mediafire.com/download/hz5tptkgftwdipw/Tower_Defense.rar
它只有 15KB 并且使用 CS6 请帮助!