How do I use audio?

0 favourites
  • 8 posts
From the Asset Store
100+ Musical High Quality Sound Effects for your game!
  • I really need help with this.

    I have tried making this work and i just can´t understand why.

    Im trying to simply make a button that controls the state of the audio.

    Since i cant post capx or links im just gonna write down the "code" that i have inserted.

    I have a very basic sprite with 2 animation frames. In the first frame it´s color is blue and in the second its black.

    I have a single numerical type global variable called sound.

    The music file format was wav. so it was converted just fine.

    Heres what i have "coded":

    Global number Sound= 0

    System - On start of layout - Stop Sprite animation.

    - Play Audio_File looping at volume 0 db( tag "Music")

    Touch - On touched Sprite - Add 1 to Sound.

    System - Sound > 1 - Set Sound to 0.

    System - Sound=0 - Set animation of Sprite to 0

    - Play Audio File looping at volume 0 db( tag "Music")

    System - Sound=1 - Set animation of Sprite to 1

    - Stop "Music".

    End of Code

    However this doesnt work and i simply dont understand why or what im doing wrong.

    Someone help me pls i have been on this problem for hours now

  • Hi, Husui.

    Take a look at my examples.

    The sound will play stacked, if you don't put 'System -> Trigger Once'.

    I had to extend the Sound global variable to 2 in order to avoid the sound from playing automatically while at 0.

    This capx example one is based on your codes. Notice we need to tap the Blue square twice to get it working.

    https://www.dropbox.com/s/g8930hy0jtj3z ... .capx?dl=0

    And this one is mine.

    Notice I've put a Wait of 0.1 second to make this work. I don't know what 'Wait 0.1 second' does in the C2 background, but it allowed me to do a lot of things that got me stuck for days while developing games.

    https://www.dropbox.com/s/pt09ng9fpzgxa ... .capx?dl=0

  • Thanks for the reply. However i believe the problem lies when i try to use a music and not a sound.

    I tried it again and did exactly the same events that you posted on your examples and it still doesnt work.

    it works if i use a sound like for example the mario jumping sound but when i try to get construct to play a music instead i simply hear nothing.

    I´m really confused...

  • Thanks for the reply. However i believe the problem lies when i try to use a music and not a sound.

    I tried it again and did exactly the same events that you posted on your examples and it still doesnt work.

    it works if i use a sound like for example the mario jumping sound but when i try to get construct to play a music instead i simply hear nothing.

    I´m really confused...

    You're welcome, Husui. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    That's odd. Unless the music file was not imported properly, it should work.

    Please upload the capx file to Dropbox, if possible.

    https://www.scirra.com/tutorials/42/upl ... to-dropbox

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think i did it right if so here it is:

    dropbox.com/s/mpt5jk0cp9z1v ... .html?dl=0

  • Ouch, the URL got cut off.

    Please remove https:// from the URL and post the address like below.

    dropbox (dot) com/s/blbdpw4vt80qdla/Gmoney%20-%20road%20-%20sprite%20animation%20V4.capx?dl=0

  • huh i dont really know how to.

    never used dropbox before i tried to send you a pm but not even that i am allowed to do.

    these restrictions are really annoying to say the least, all i wanted was help...

    sorry gmoney im a really big noob.

  • huh i dont really know how to.

    never used dropbox before i tried to send you a pm but not even that i am allowed to do.

    these restrictions are really annoying to say the least, all i wanted was help...

    sorry gmoney im a really big noob.

    No problem, Husui. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    I'm so sorry for the troubles you had to go through with Dropbox. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    I have updated the following capx file with a music file.

    https://www.dropbox.com/s/pt09ng9fpzgxa ... .capx?dl=0

    The capx file is designed to take any music or sound files without any issues and I have tested to confirm they're working.

    The music files destined for the C2 use must be encoded in to two formats: Ogg Vorbis (.ogg) and MPEG-4 AAC (.m4a).

    Based on my experience, it's best to use .WAV files as the source file before converting them to .ogg or .m4a.

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