Help with an array

Get help using Construct 2

Post » Sat Oct 19, 2013 8:25 pm

Hey guys. I feel kinda dumb right now because I've been trying all day long to figure something out that I think should be easy but I can't get it to work. I have an array populated with words such as "cat, dog, horse" etc... I want to associate each word in the array with a sound and then when the payer enters a word into a text box, if that word is contained in the array I can get the associated sound file to play (not right away, I would call it to play later). So the player types "cat" in the text box, and it remembers "meow.wav" and I can load and play that sound at a later time. If anyone would be willing to post an easy to understand capx of how to do that I would really appreciate it. This has been bugging me because it seems like it should be easy to do. Thank you very much.
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941

Post » Sat Oct 19, 2013 9:24 pm

http://s000.tinyupload.com/index.php?file_id=01220764061650594255

just setup the height of the array to two and width to number of different animals
You could take the easy way out and prevent the second dimension by just generating the wav-names out of the animal name. So in the example set next_sound to "sound_"&string&".wav" and next_sound would be sound_cat.wav for example.

What's bugging me is: cat doesn't work, but dog and bird does. Also adding .wav behind woof would make the dog stop working as well. Really really weird. Maybe I did something wrong, but can't see the problem if there is one. (maybe someone can help)

If you don't want the comparison to be case sensitive, compare the strings as lowercase (use lowercase(string))mindfaQ2013-10-19 21:40:33
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sat Oct 19, 2013 9:25 pm

ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Sat Oct 19, 2013 9:58 pm

Thank you very much! This is very helpful!
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941


Return to How do I....?

Who is online

Users browsing this forum: ksiads and 1 guest