There was a small problem with the 2D and 3D audio action where by, if the action was disabled in scene edit mode it would not play when dynamically setting the action to enabled in play game mode. I have fixed the action for you and it will be in the next release.
Try this script when you get the update as it is designed to turn on/off the actions when entering or exiting a game state. This way you could enter the first state and do your narration then switch back to main state and the sounds will run.
Note:requires update for audio to work correctly.
- Code: Select all
function onInit(objID)
-- Set all audio objects tag name to "audio_1","audio_2","audio_3", "audio_x" etc
-- then you could do the following:
sky.setGameState(enum.GS_GamePaused());
-- use the game paused events to do your intro naration
-- then switch back to the main game state when ready to play.
end
function onKeyDown( key )
if(key=="1") then sky.setGameState(enum.GS_GamePaused()); end
end
function onKeyDown_GamePaused( key )
if(key=="2") then sky.setGameState(enum.GS_GameMain()); end
end
--Enter into the Paused game state and only use pause related functions.
function onEnter_GamePaused( )
for i=1,4 do enableAduio(i,"false"); end
end
-- Entering into the normal Main Game state.
function onEnter( )
for i=1,4 do enableAduio(1,"true"); end
end
function enableAduio(audioID, state)
targetID = entity.getIDFromTag("audio_"..audioID)
actionID = action.getActionID(targetID, "Audio - 3D Positional");
action.setActionParam(targetID, actionID, "A3D Enabled", state);
end
At the moment I think this would be your best bet.