How to play a sound from variable

Get help using Construct 2

Post » Thu May 16, 2013 5:28 am

I have the song names stored in variables,
But I cannot figure out how to play them.

How do you make the play action reference the string in the variable?

B
16
S
2
G
3
Posts: 61
Reputation: 2,346

Post » Thu May 16, 2013 5:38 am

Audio File Name should just be the variable name. like Song7 (no quotes)

I just tested it and it seemed fine. Unless you are trying to do something trickier?

Example CAPX
Sound Play By NameArcadEd2013-05-16 05:41:43
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Thu May 16, 2013 5:50 am

I see what you're trying to do.. have you tried using str("Song"&CurrentSong)?
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Thu May 16, 2013 5:59 am

Use a dictionary object
Add key "Song1" value "name of the song here"

Then
Play by name Dictionary.Get("Song"&CurrentSong)
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Mon May 20, 2013 1:17 am

Thank you 7Soul, that is exactly what I was looking for.

And what a handy object to learn about!
B
16
S
2
G
3
Posts: 61
Reputation: 2,346


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 24 guests