Resource manager provides functions to add, get and remove resources. More...
#include <ResourceManager.hpp>
Public Member Functions | |
void | addMusicResource (std::string key, Mix_Music *music) |
Add music resource into a map. More... | |
Mix_Music * | getMusicResource (std::string key) |
Return specified music resource based on its name. More... | |
void | removeMusicResource (std::string key) |
Remove specified music resource based on its name. More... | |
void | addSoundResource (std::string key, Mix_Chunk *sound) |
Add sound resource into a map. More... | |
Mix_Chunk * | getSoundResource (std::string key) |
Return specified sound resource based on its name. More... | |
void | addTextDisplayResource (std::string key, TextDisplay *textDisplay) |
Add TextDisplay component into map. More... | |
TextDisplay * | getTextDisplayResource (std::string key) |
Return specified TextDisplay class. More... | |
void | removeTextDisplayResource (std::string key) |
Remove specified TextDisplay class. More... | |
void | addGameComponent (std::string key, Component *component) |
Add classes that inherits Component.h into map. More... | |
Component * | getComponentResource (std::string key) |
Return specified component resource. More... | |
void | removeGameComponent (std::string key, Component *component) |
Remove specified component resource. More... | |
void | addFont (std::string key, TTF_Font *font) |
Add font resource into map. More... | |
TTF_Font * | getFont (std::string key) |
Return specified font resource. More... | |
void | write2Json (const char *const filePath, const char *const data) |
write data into the json file. More... | |
char * | readFromJson (const char *const filePath) |
Read data from json file. More... | |
~ResourceManager ()=default | |
void | destroy () |
Free the loaded music, free the memory used by font, and free font itself as well, delete text resources. More... | |
Static Public Member Functions | |
static ResourceManager * | getInstance () |
Resource manager provides functions to add, get and remove resources.
|
default |
Destructor.
|
inline |
Add font resource into map.
key | The name of the font rosource. |
font | The reference to the TTF_font. |
|
inline |
Add classes that inherits Component.h into map.
Currently you can add TileMap, TilemapEditor, GameState, Camera, Sprite, Animation as well as TextDisplay by using this function once then inherits Component.h.
key | The name of the component. |
component | The reference of the component. |
|
inline |
Add music resource into a map.
key | The name of this resource. |
music | The reference to Mix_Music. |
|
inline |
Add sound resource into a map.
key | The name of this resource. |
sound | The reference to Mix_Chunk. |
|
inline |
Add TextDisplay component into map.
key | The name of this component. |
textDisplay | The reference of the TextDisplay class. |
|
inline |
Free the loaded music, free the memory used by font, and free font itself as well, delete text resources.
|
inline |
Return specified component resource.
key | The name of the component you want. |
|
inline |
Return specified font resource.
key | The name of the font resource you want. |
|
inlinestatic |
Return the reference of the singleton ResourceManager.
|
inline |
Return specified music resource based on its name.
key | The name of the resource you want. |
|
inline |
Return specified sound resource based on its name.
key | The name of the resource you want. |
|
inline |
Return specified TextDisplay class.
key | The name of the TextDisplay class you want. |
|
inline |
Read data from json file.
filePath | The address of the json file. |
|
inline |
Remove specified component resource.
key | The name of the component you want to remove. |
component | The reference of the component. |
|
inline |
Remove specified music resource based on its name.
key | The name of the resource you want to delete. |
|
inline |
Remove specified TextDisplay class.
key | The name of the TextDisplay class you want to remove. |
|
inline |
write data into the json file.
filePath | The address of the json file. |
data | The data in json file. e.g. "Enemy1": { "id": 1, "isActive": true, "posX": 32, "posY": 320 }, "Enemy2": { "id": 2, "isActive": true, "posX": 128, "posY": 352 }, ... |