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
12
Posts: 1,549
Reputation: 22,033

Post » Thu May 16, 2013 5:50 am

I see what you're trying to do.. have you tried using str("Song"&CurrentSong)?
B
129
S
44
G
41
Posts: 857
Reputation: 28,485

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
86
S
22
G
15
Posts: 1,039
Reputation: 15,314

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: Google [Bot] and 59 guests