Skip to content

Instantly share code, notes, and snippets.

@nipundavid
Last active December 24, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nipundavid/6796639 to your computer and use it in GitHub Desktop.
Save nipundavid/6796639 to your computer and use it in GitHub Desktop.
package com.example.samplegame;
import org.andengine.engine.options.EngineOptions;
import android.content.Context;
public class ResourceManager {
// ResourceManager Singleton instance
private static ResourceManager INSTANCE;
/* The variables listed should be kept public, allowing us easy access
to them when creating new Sprites, Text objects and to play sound files */
ResourceManager(){
// The constructor is of no use to us
}
public synchronized static ResourceManager getInstance(){
if(INSTANCE == null){
INSTANCE = new ResourceManager();
}
return INSTANCE;
}
/* Each scene within a game should have a loadTextures method as well
* as an accompanying unloadTextures method. This way, we can display
* a loading image during scene swapping, unload the first scene's textures
* then load the next scenes textures.
*/
public synchronized void loadGameTextures(EngineOptions pEngine, Context pContext, org.andengine.engine.Engine mEngine){
// Set our game assets folder in "assets/gfx/game/"
}
/* All textures should have a method call for unloading once
* they're no longer needed; ie. a level transition. */
public synchronized void unloadGameTextures(){
}
/* As with textures, we can create methods to load sound/music objects
* for different scene's within our games.
*/
public synchronized void loadSounds(EngineOptions pEngine, Context pContext, org.andengine.engine.Engine mEngine){
}
/* In some cases, we may only load one set of sounds throughout
* our entire game's life-cycle. If that's the case, we may not
* need to include an unloadSounds() method. Of course, this all
* depends on how much variance we have in terms of sound
*/
public synchronized void unloadSounds(){
}
/* Lastly, we've got the loadFonts method which, once again,
* tends to only need to be loaded once as Font's are generally
* used across an entire game, from menu to shop to game-play.
*/
public synchronized void loadFonts(EngineOptions pEngine, Context con, org.andengine.engine.Engine mEngine){
}
/* If an unloadFonts() method is necessary, we can provide one
*/
public synchronized void unloadFonts(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment