A part of what i'm making involves having a button which, when clicked, plays a random sound from a list of sound files. I did this by creating a list and inserting the sounds into the list. Let's say there's 3 sounds - cow, pig and chicken.
What I want to happen now is when I click the button and hear the animal sound, I need to click the correspondent button.
First two blocks create the list, the second group of blocks insert the sounds into the list and the third group of blocks is a fragment of what i'm trying to find out now. In normal programming i'd just create a variable and save whichever sound was played onto that variable, and then use an "if{} else if{} else{}" and use gets to get the value of the variable, though with MIT App Inventori'm not sure how I can get it to know which was the last sound that was played.
--
use the random integer block instead of the pick a random item block, see this example https://puravidaapps.com/snippets.php#2removerandom
removerandom.aia
share.aia
-- removerandom.aia
share.aia
I want them to remain in the list though. I click the Randomize button and hear, let's say a dog, click the button for the dog and it'll say whether i'm right or wrong.
Then I click the Randomize button again and it has a chance of any of the 3 showing up again.
--
use the random integer block as already mentioned and adjust the provided example to your needs
--
Finally got it!
I used the randomsound component linked to the randomize button, left it blank, changed it's source to whichever file was randomly pulled from the list and did my "if{} else if{} else{}" comparisons based on the current randomsound source.
--
댓글 없음:
댓글 쓰기