Game Development Community

Playing Music in the Main GUI

by Alejandro Lopez · in General Discussion · 05/19/2008 (9:33 pm) · 2 replies

When the user launch the game , its show the main GUI, i want to play a song , this is my code
datablock AudioDescription(sonidosGUI){   // sonido 2d
   volume      = 1;
   isLooping   = false ; 
   is3D        = false;     
   type        = $GuiAudioType;
      
};
// AUDIO PROFILES
datablock AudioProfile( SonidoGuiPpal){
   filename    = "~/data/sound/principal.ogg";
   description =   sonidosGUI;
};

but , if not working, i understand the problem , its because, the datablocks are not sended yet to the client.
how can i send this datablock or play the music in the first screen ?

#1
05/19/2008 (9:54 pm)
Into your 'onWake' function in main GUI script.

follow this example.
function mainGUI::onWake( %this )
{
   [b]alxplay( SonidoGuiPpal );[/b]
}

if you want stop audio, when close screen.
function mainGUI::onSleep( %this )
{
   [b]alxstop( SonidoGuiPpal );[/b]
}
#2
05/20/2008 (9:21 am)
For GUI sounds ( and music ) that the client determines when to play ( eg. sound is played through a gui's onwake, not a serverPlay2D for example ), the profiles should be defined ON the client side only. Then you do not have a ghosting issue.