We almost never recommend globals given there are other options. See: http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/
mydata.lua -- local M = {} M.isAudioPlaying = false return M scene\_menu.lua : local myData = require("mydata") if myData.isAudioPlaying == false then audio.reserveChannels( 1 ) audio.play(backgroundMusic,{ channel = 1, loops = -1 }) isAudioPlaying = true end
If you use the cross scene audio blog, it’s in effect doing the same thing as the Goodbye globals blog. It’s returning a data table with your audio handles in it. If you want to pre-load your audio in main.lua and use it in later scenes, you would need to have a module like this that contains the handles you create in main.lua. If you use the cross-scene audio tutorial, that table can contain your .isAudioPlaying.