0

こんにちは、私はアクション スクリプト プログラミングが初めてで、これを正しく行う方法がわかりません。

このゲームにはスコアとタイマーが必要です >>> http://www.filedropper.com/eggrun

スコアを追加するためのコインと、ゲーム時間のカウントダウン タイマーが必要です。

みんな助けてください:(

私はこれを正しくすることにどこにも近づいていません。:(

4

1 に答える 1

1

いくつかのコードが役立ちます。しかし、単純なカウントダウン タイマーを作成するには、これを試してください。「タイムライン」でのコーディングを想定しています

var count:Number = 60; //Count down from 60

var myTimer:Timer = new Timer(1000,count);// Timer intervall in ms

myTimer.addEventListener(TimerEvent.TIMER, countdown);//EventListener for intervalls
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, countdownComplete);
myTimer.start();//start Timer

function countdown(event:TimerEvent):void {
countDownTextField.text = String((count)-myTimer.currentCount); 
//Display Time in a textfield on stage, 
//i'll call it countDownTextField. U will have to create it first
}

function countdownComplete(event:TimerEvent):void {
   // fires when the countdown is finished
   removeEventListener(Event.ENTER_FRAME,onenter);//stops the game
   addChild(scoreScreen); //You have to create a Sprite or MovieClip with a TextField
   scoreScreen.scoreText.text = score.toString() // and then assign the score to the textField
//to start the game again just remove the scoreScreen and call the init() function
   myTimer.removeEventListener(TimerEvent.TIMER, countdown);//remove listers
   myTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, countdownComplete);

}

タイマーが終了したときのメソッドが必要な場合は、TimerEvent.TIMER_COMPLETE リスナーを追加してください。

あなたが何を意味するのか説明してください

スコアを追加するためのコインが必要です

スコアを処理する最良の方法は、関数を使用することです

var score:int = 0;
function updateScore(addScore:int):void{
    score += addScore;

}

そして、このようにスコアを更新する必要があるときはいつでも呼び出すだけです

updateScore(10);// adds 10 to the score
于 2013-02-23T13:10:22.537 に答える