2012-02-21 84 views
1

我需要以下游戲的認真幫助。 我想在遊戲中提出一些問題和答案,玩家必須拍攝正確的答案。 所以3個答案就像敵人一樣從右邊進入舞臺,但是慢慢地。飛船測驗遊戲Actionscript 3

我該怎麼用Actionscript 3做到這一點? 該遊戲是用OOP actionscript 3編寫的,結合Flash Pro。

你可以在這裏玩的遊戲: http://stap.iam.hva.nl/~sahina002/Spaceship/basics2.html

我用這個代碼,但不知道如何實現它。

vragen = new Vector.<QuizVraag>; 
//   vragen.push(
//    new QuizVraag("Wat is een boom?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 0 
//    new QuizVraag("Wat is een auto?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 1), // Vraag 1 
//    new QuizVraag("Wat is een bus?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2), // Vraag 2 
//    new QuizVraag("Wat is een fiets?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 3 
//    new QuizVraag("Wat is een stoel?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2) // Vraag 4   
//   ); 


package com.quiz 
{ 
public class QuizVraag 
{ 
    private var _vraag:String; 
    private var _antwoorden:Array; 
    private var _correcteAntwoordIndex:int; 

    public function QuizVraag(vraag:String, antwoorden:Array, correcteAntwoordIndex:int) 
    { 
     _vraag = vraag; 
     _antwoorden = antwoorden; 
     _correcteAntwoordIndex = correcteAntwoordIndex; 
    } 

    public function optieIsCorrect(mijnAntwoordIndex:int):Boolean 
    { 
     return _correcteAntwoordIndex == mijnAntwoordIndex; 
    } 

    public function get vraag():String 
    { 
     return _vraag; 
    } 

    public function get correcteAntwoord():String 
    { 
     return _antwoorden[_correcteAntwoordIndex]; 
    } 

    public function get correcteAntwoordIndex():int 
    { 
     return _correcteAntwoordIndex; 
    } 

    public function get antwoorden():Array 
    { 
     return _antwoorden; 
    } 
} 
} 

感謝,

阿里

+0

好吧,如果這些單詞是英文的話會更容易。似乎vraag是問題和antwoorden,答案。 – 2012-02-25 12:36:06

回答

0

好吧,

到目前爲止,您已經對代碼有什麼解決如果某一指數爲正確答案的邏輯。

但你錯過了顯示答案和子彈碰撞的所有邏輯。

基本上你需要的是一個引擎,它將把圖像和索引關聯到主題的DisplayObject(可能是Sprites)。因爲答案是唯一的整數,你可以使用相同的密鑰(答案指數&的z-index /深度指數)

然後你只需要檢查衝突(你可以做到這一點的onEnterFrame事件),運行測試碰撞每個displayObject aka answer,如果發生衝突,您可以使用您提供的邏輯來設置結果是否正確。

希望它有幫助!

+0

嗨,我需要修復這個遊戲的學校項目。 你能給我提示如何做到這一點。圖爲我們的概念。 你將不得不拍攝出好的答案。當你打錯了答案,你會失去一個生命(心臟) 我認爲這是可能的與collissions和如果和其他聲明像你說的。 http://stap.iam.hva.nl/~sahina002/game.jpg 我們非常感謝您的幫助。 -Ali – 2012-03-07 11:55:32