简体   繁体   中英

Spaceship Quiz game Actionscript 3

I need serious help with the following game. I want to put some questions and answers in the game, where the player has to shoot the right answer. So the 3 answers come onto stage from the right just like the enemies but slowly.

How can I do this with Actionscript 3 ? The game is written in OOP actionscript 3, combined with Flash Pro.

You can play the game here: http://stap.iam.hva.nl/~sahina002/Spaceship/basics2.html

I used this code but dont know how to implement it.

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;
    }
}
}

Thanks,

Ali

Ok,

So far what you have on that code is the logic to solve if a certain index is the correct answer.

But you are missing all the logic about displaying answers, and bullet collision to them.

Basically what you need is an engine which pushes the answers as DisplayObjects ( probably Sprites ) that will have an image and an index associated to theme. Since answers are unique integer numbers you could use the same key ( answer index & z-index / depth index )

Then you only have to check for collisions ( you may do that on onEnterFrame event ), run a test collision for every displayObject aka answer and if there is a collision you can use the logic you provided to set if the result is correct or not.

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM