Copy link to clipboard
Copied
I'm trying to make a simple True/False game in Animate. I need the game to randomly select a question out of 10 options, ask each question once (no repeats). I have the game questions on labeled keyframes ("q1", "q2"...) I've tried several suggestions that I found online, and none seem to work--creating array, not creating array, using variables. I don't have any example code to show, as nothing is coming close to working. Any suggestions?
There is nothing wrong with your code above. It works just fine for me in a standalone file. You say that using random breaks the file, can you give a more complete description of what is happening?
Copy link to clipboard
Copied
Is this for Actionscript or for an HTML5 Canvas file? What do you want to have happen when the user chooses the correct versus the incorrect answer? Can you share the sample files that you have tried that failed for you? Can you tell us why they didn’t work for you?
Copy link to clipboard
Copied
HTML5 Canvas.
When the user chooses the correct answer, the score should augment +1, and they should be taken to the next randomly selected keyframe. User does not need to be taken to a "correct!" type frame.
When I've tried to put in anything random, it breaks the game, and I'm (obviously) not knowledgable enough to fix it.
The only code I still have on hand is:
var adFramesA = ["q1","q2","q3"];
this.gotoAndPlay(adFramesA[Math.floor(adFramesA.length*Math.random())]);
I got this from an online source, so don't know much about it. If there's an online suggestion for how to do this, I've tried it with no success.
Copy link to clipboard
Copied
There is nothing wrong with your code above. It works just fine for me in a standalone file. You say that using random breaks the file, can you give a more complete description of what is happening?