如何在“gameover”屏幕中清除“游戏”界面中的内容?

时间:2011-12-09 03:05:59

标签: actionscript

我添加了一些东西,比如减去分数,然后添加另一个帧,这样当我无法捕捉到一个物体五次时,我会进入“GameOver”屏幕。但是,我无法从“GameOver”界面的“游戏”界面清除这些内容。我该怎么做?我从http://flashgameu.com/Catching_Game_Part_2_id20090312-131621.html获得了我的源代码。

无论如何,这是我的actionscript 3.0代码:

包{     import 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()中的所有内容,但我无法让它工作....

1 个答案:

答案 0 :(得分:0)

屏幕上还有什么,你想删除什么?

看起来 girlmouth 符号是您要删除的主要符号。如果是这种情况,请试试这个:

if (missedItems == 5) {
    removeChild(girlmouth);
    removeEventListener(Event.ENTER_FRAME, moveObjects);
    gotoAndStop(2);
    finalScoreDisplay.text = "Score: "+score;
}