Play Audio & Function param problem

Get help using Construct 2

Post » Tue Dec 03, 2013 11:12 pm

I've set up a series of sprite & instance name of the audio they each assigned to, when player click on the sprite, function will send param of the audio name to "play (by name)", in "audio file name", i tried giving it just the function.param(0), it didn't work, i know it take string only, then i tried """&function.param(0)&""" it wouldn't play as well.

how can i make it play audio from the function param name i send to?
Doo Doo Diving App Store | Google Play

Donut Pirate App Store | Google Play
B
17
S
2
G
1
Posts: 195
Reputation: 1,578

Post » Wed Dec 04, 2013 3:09 am

@hollowthreat

Hey there. Make sure the instance name being passed is a string, first off. I did something similar and set an instance variable with the string name, which is then passed to a function to play the audio.

In your case, try setting a sprite's instance variable string to the name of the audio file it should play when clicked. Clicking on the sprite can call a function or play the audio directly, using the instance variable as the file name.

If I mis-read your question, my bad! ;)
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Wed Dec 04, 2013 7:28 am

@Space Ape
thank you so much, that just clicked! the instance i set was number, that explains why, i thought i could just name them in numbers, same as the audio files, but it wouldnt work. now i'll change them to text instance. :)
Doo Doo Diving App Store | Google Play

Donut Pirate App Store | Google Play
B
17
S
2
G
1
Posts: 195
Reputation: 1,578

Post » Thu Dec 05, 2013 9:06 pm

@hollowthreat

Anytime, amigo. If you're using instance variables / numbers, you could also use the str() expression to convert the number to a string matching a corresponding audio file, then pass that converted string to the audio.

Either way, I hope it works out for you and good fortunes with your project!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Fri Dec 06, 2013 12:19 am

@Space Ape
thanks again, that was very helpful! i've redo the instance in text already, and working fine, so i'll try str() next time :)
Doo Doo Diving App Store | Google Play

Donut Pirate App Store | Google Play
B
17
S
2
G
1
Posts: 195
Reputation: 1,578


Return to How do I....?

Who is online

Users browsing this forum: babymumu, dop2000, draiza and 4 guests