Reputation: 21072
I have a game with images -- I would like to cache them silently before the games begins. Thus I can have two scenarios:
OR
For the second case, I could pass to caching function a callback to run the game. But since first case can happen I cannot do this, because I have to wait for the user as well.
So now I am thinking about having global (ouch) variable which would be a callback onGameStart
. By default it would be displaying progress, but caching callback would do two things -- reset onGameStart
to actually starting the game, and checking if the game was started, if it was, it would continue immediately.
Did I miss something? Is it the right pattern?
Upvotes: 0
Views: 74
Reputation: 7576
What about a ResourceObserver that gets a notification when the ResourceManager has fetched all the resources? Then your game keeps state, and if the user starts a game before the notification, use the progress notifications to update the screen, otherwise, just skip to the game.
TL;DR: Observer+State Machine.
Upvotes: 1