Game Development Community

Importing an audio and volume changes

by KaiserImpact · in Torque 2D Beginner · 02/07/2014 (3:57 am) · 4 replies

Hello all. I've being look into the audio tutorial over here https://github.com/GarageGames/Torque2D/wiki/AudioAsset-Guide. But i'm unable to create the audio in the scene due to lacking of info. Basically i've done the part below.

<AudioAsset
AssetName="level1Music"
AudioFile="music/TD_Medieval_GameplayAudio.wav"
/>

But i've no idea how to continue in the script. i've looked inside the torquescript reference created by doxygen but there's no audioasset class to reference with. So, can any1 provide me an example on how to use the piece of music in the script? Thanks loads!

#1
02/07/2014 (4:11 am)
Check out the AudioBasicsToy from here:

github.com/t2Dtutorials/Modules

That will give you some practical examples for audio in script.
#2
02/07/2014 (7:42 am)
hello mike again. thanks for the wonderful toy. But again, how do i increase or decrease the volume of the music? May i know whats the method for it? for now i am currently using this line of code.

%sound = alxPlay("TestToy:bgm");

Thanks once again!

#3
02/07/2014 (7:56 am)
There's a list of audio functions here:

garagegames.github.io/Torque2D/TorqueScriptDocs/html/group__AudioFunctions.html

I would assign the audio asset a volume channel and use alxSetChannelVolume.
#4
02/07/2014 (8:23 am)
oh my.. i failed to arrive that page. thanks and its working very well and i'm pleased to meet such nice community and enjoyed myself using torque2d as my project.