Advertisement

How do I access a single object from multiple objects efficiently?

Started by September 10, 2002 01:27 PM
2 comments, last by ReaperX 22 years, 3 months ago
I want almost all my objects to be able to access a class that handles sprites and draws them to the screen or a class that stores and sorts gameworld events. What would be the most efficient way to handle this in c++? Is there any flaw in this idea and is there a better way to get my objects to interact with the screen or each other? thanks for any help.
Give each of them a pointer to the class...
Advertisement
So you think if I spawn a load of monster objects that I should pass each one a pointer when its loaded? What if the monsters are part of another class, should I pass the pointer to that class first? I was thinking of using a static object (if there is such a thing). I suppose i could multiple inherit a static pointer to all drawable objects. Is there a better method?
make the class a static singleton. search more info about the singleton pattern.

This topic is closed to new replies.

Advertisement