The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsI want to make this little thing where, lets say I click a button and it selects a random phrase that I have typed out and tells the player that.
Example:
Phrases (You're horrible at this. You're great at this)
And then when you click the button then it chooses one of those phrases and says that.
Does anyone know how to do this? I was thinking maybe arrays, but I am not sure how to use those... Any help would be appreciated
Just have an array holding all your string, for when you press your button just do it randomize and pick the sorted value from the array
Example:
var array:Array = new Array("blah", "bleh", "blih");
var integer:int = Math.random()*3;
trace(ar[id]);
It will random pick one of the values you have in your array, hope this helps :)
Oh sorry:
[...]
trace(ar[integer]);
Hope this helps :)
ARGH!
trace(ar[integer]);
// sorry, I wrote this code for one of my projects and just changed the names to you understand, sorry -.- \\ WHAT IS HAPPENING? I DID THE MISTAKE AGAIN!! ARGH!
trace(array[integer]);
=O WHAT IS HAPPENING? LOL
Here is a nice function you could save into a class package for use later on:
private function randRange(minNum:Number, maxNum:Number):Number
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}
You could use it for instance like this;
enemyThing = randRange(0, myArray.length);