0
我添加了一些東西,例如減去分數,並添加了另一個框架,以便當我無法抓住對象五次時,我就可以進入「GameOver」屏幕。但是,我無法從「GameOver」屏幕的「遊戲」屏幕中清除這些內容。我該怎麼做?我得到了我的源代碼:http://flashgameu.com/Catching_Game_Part_2_id20090312-131621.html。如何清除「gameover」畫面中「遊戲」畫面的內容?
總之,這裏是我的ActionScript 3.0代碼:
包{ 進口com.greensock *。
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
import flash.utils.getDefinitionByName;
public class CatchingSkittles extends MovieClip {
var girlmouth:GirlMouth;
var girlmouthfront:GirlMouthFront;
var nextObject:Timer;
var objects:Array = new Array();
var score:int = 0;
var missedItems:int = 0;
var speed:Number = 7.0;
public function CatchingSkittles() {
girlmouthfront = new GirlMouthFront();
girlmouthfront.y = -49.00;
girlmouth = new GirlMouth();
girlmouth.y = 308.55;
addChild(girlmouth);
girlmouth.addChild(girlmouthfront);
setNextObject();
addEventListener(Event.ENTER_FRAME, moveObjects);
}
public function setNextObject() {
nextObject = new Timer(1000+Math.random()*1000,1);
nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject);
nextObject.start();
}
public function newObject(e:Event) {
var goodObjects:Array = ["Red","Purple","Yellow","Orange","Green"];
if (Math.random() < .8) {
var r:int = Math.floor(Math.random()*goodObjects.length);
var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;
var newObject:MovieClip = new classRef();
newObject.typestr = "good";
} else {
r = Math.floor(Math.random()*goodObjects.length);
classRef = getDefinitionByName(goodObjects[r]) as Class;
newObject = new classRef();
newObject.typestr = "good";
}
newObject.x = Math.random()*510;
addChild(newObject);
objects.push(newObject);
setNextObject();
}
public function moveObjects(e:Event) {
for(var i:int=objects.length-1;i>=0;i--) {
objects[i].y += speed;
if (objects[i].y > 425) {
score -= 5;
removeChild(objects[i]);
objects.splice(i,1);
missedItems +=1;
if (missedItems == 5) {
gotoAndStop(2);
finalScoreDisplay.text = "Score: "+score;
}
}
if (objects[i].hitTestObject(girlmouthfront)) {
if (objects[i].typestr == "good") {
score += 5;
} else {
score += 5;
}
removeChild(objects[i]);
objects.splice(i,1);
}
scoreDisplay.text = "Score: "+score;
}
girlmouth.x = mouseX;
}
}
}
我一直在試圖編輯在 「missedItems」 在功能moveObjects一切(),但我不能讓它工作....