Play Audio & Function param problem

0 favourites
  • 5 posts
From the Asset Store
For problem solving, puzzles, bubbles, platforms and other adventures.
  • 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? <img src="smileys/smiley19.gif" border="0" align="middle" />

  • 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! ;)

  • 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. :)

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)