Hi,
From experience of writing my previous games, I used an audio manager that each object can access if it wants to playback a sound effect. So I was thinking of doing the same thing with Corona but due to the nature of Lua, I find it not that obvious as it is in regular languages.
What I used to do is to create a static class so each object can access it directly and either asks that class to play sound for him or get handle of preloaded sound effect and play it back himself (so he can listen to it’s events, if he’s interested).
So how can I achieve such thing with Lua?
Things that prevented me from writing this on my own are:
1- How to make sure that class is initialized once because if I put require(“audio_manager”) on top of every class that wants to play a sound, I have no idea if Lua/Corona goes and loads all files for every require call.
2- How to give it’s handle to every object that wants to access it? Should I pass it’s handle as a parameter to my constructors?
first step would be on how to initialize a class once and load all SFX’s there and share it between different objects so they would not each init that class.
Thanks. [import]uid: 206803 topic_id: 35993 reply_id: 335993[/import]