Game Development Community

Using level specific Audio datablock files

by Richard Skala · in iTorque 2D · 10/13/2010 (12:43 am) · 3 replies

Is there a safe, reliable method for using level specific audio datablock files?

I have a simple idea for it, and I was wondering if this would be safe.

In game.cs, inside 'startGame(%level)', I simply check against the level that is about to be loaded, and execute the appropriate script containing audio data blocks.

This does load the audio, but is doing it this way safe? That is, when a level is ended and unloaded, are those audio datablocks unloaded along with all the other assets in the level?

In game.cs, at the top of function startGame():
%levelFileName = fileName( %level );
	
if( strcmp( %levelFileName,  "Screen_MainMenu.t2d" ) == 0 )
{
	exec( "./AudioDataBlocks_MainMenu.cs" );
}
else if( strcmp( %levelFileName, "Screen_MapSelect_PowerUp.t2d" ) == 0 )
{
	exec( "./AudioDataBlocks_MapAndPowerUpScreen.cs" );
}
else
{
	exec( "./AudioDataBlocks_Levels.cs" );
}

#1
10/13/2010 (1:23 am)
datablocks are datablocks and should all be in the per level datablock file optimally if you ask me.

with audio you just have the problem that part of it won't even have datablocks (compressed audio)
#2
10/13/2010 (1:59 am)
I thought about putting them in the per-level datablock files, but if I need to edit them in the TGB editor, won't the entire file get overwritten?
#3
10/14/2010 (1:36 am)
Actually, I just realized that my method cannot work, since the script "startGame()" is only called once, when the game first loads.