- Home /
This question was
closed Feb 05, 2014 at 05:37 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Question by
Jacques993 · Feb 05, 2014 at 05:35 PM ·
guiarraysquiz
Making A Question Based Game, How to Ask Randomly
Just working with arrays & GUI using Javascript and wondering what is the best approach to asking random questions from a bank of questions in an array?
Currently using the following method to ask questions when reaching a point but it is obviously rather static i.e. correct answer button in fixed place every time.
function OnGUI ()
{
if (drawGUI == true)
{
GUI.skin = MenuSkin;
GUI.Box (Rect (Screen.width*0.5-51, 200, 402, 22), "What is the Second Letter in the Alphabet?");
if (GUI.Button (Rect (Screen.width*0.5-51, 230, 198,20), "A")) {
GameObject.Find("First Person Controller").GetComponent(PlayerStats).playerScore -=2;
}
if (GUI.Button (Rect (Screen.width*0.5+153, 230, 198,20), "C")) {
GameObject.Find("First Person Controller").GetComponent(PlayerStats).playerScore -=2;
}
if (GUI.Button (Rect (Screen.width*0.5+153, 260, 198,20), "D"))
{
GameObject.Find("First Person Controller").GetComponent(PlayerStats).playerScore -=2;
}
if (GUI.Button (Rect (Screen.width*0.5-51, 260, 198,20), "B")) {
GameObject.Find("First Person Controller").GetComponent(PlayerStats).playerScore +=10;
changeDoorState();
}
}
Any help would be greatly appreciated
Comment