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
15
S
2
G
3
Posts: 61
Reputation: 2,321

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
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Thu May 16, 2013 5:50 am

I see what you're trying to do.. have you tried using str("Song"&CurrentSong)?
B
106
S
35
G
36
Posts: 793
Reputation: 24,705

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
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

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
15
S
2
G
3
Posts: 61
Reputation: 2,321


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests