Sign in to follow this  
THACO

Sound

Recommended Posts

I am currently designing and creating a simple engine. I am working on sound now. I currently have a sound class, which can play sounds. My one problem I just thought is how do I tell this class to play certain sounds during the game play loop. I will be having a player or character classes deal with where the player is and what the player is doing. This class will probably ulitmately decide if a specific sound should be played. It would be nice if I had an instance of the sound class inside so when i feel it is neccesary to play a sound I can just call sound->playsound(HIT); Should I just send a pointer to the class I created in my basecode to the player function that will take care of the decision making for what animation, movement, and sound? Or should I try something else? I am currently using FMOD for sound. -THACO

Share this post


Link to post
Share on other sites
You could possibly declare it is a global and make it a singleton. This might make it so at least your not overusing the resources by making it static.

Or simply put it in a pre compiled header file of some sort. That is the routes id choose and in fact currently use. Passing it as an argument constantly seems like it would create a lot of overhead. Also, it tends to get annoying passing it as an argument, especially if you want to change things later.

Share this post


Link to post
Share on other sites
Ok, I created a singleton, the one question I have, how can I access it in other objects when I init those objects do I then just send them the pointer? In my main source file I have it as global, but does that mean I can use it in the other source files that I include after I declared the log object?

-THACO

Share this post


Link to post
Share on other sites
Ah, that worked, I tried is as extern in the main source, but I had to do it in the source for the other object. Thanks a lot

-THACO

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this