Skip to content

Class Engine::AssetManager

ClassList > Engine > AssetManager

Singleton class to load, store, and manage game audio assets.

  • #include <AssetManager.hpp>

Public Functions

Type Name
AssetManager () = default
AssetManager (const AssetManager &) = delete
AssetManager (AssetManager &&) = delete
void ClearAll ()
std::unordered_map< std::string, std::shared_ptr< Music > > & GetAllMusic ()
std::unordered_map< std::string, std::shared_ptr< Sound > > & GetAllSounds ()
std::shared_ptr< raylib::Font > GetFont (const std::string & alias)
std::shared_ptr< Music > GetMusic (const std::string & alias)
std::shared_ptr< Sound > GetSound (const std::string & alias)
std::shared_ptr< Sprite > GetSprite (const std::string & alias)
Retrieves a sprite by its alias.
void LoadFontFromMemory (const std::string & alias, const std::string & fileType, const unsigned char * fileData, int dataSize, int fontSize=12, int * fontChars=nullptr, int charsCount=0)
void LoadMusic (const std::string & alias, const std::string & filePath, bool isLoop=false)
Clears all loaded assets (sounds and sprites).
void LoadMusicFromMemory (const std::string & alias, const char * fileType, const unsigned char * data, int dataSize, bool isLoop=false)
void LoadSound (const std::string & alias, const std::string & filePath, bool isLoop=false)
void LoadSoundFromMemory (const std::string & alias, const char * fileType, const unsigned char * data, int dataSize, bool isLoop=false)
void LoadSprite (const std::string & alias, const std::string & filePath)
Loads a sprite texture from a file path and assigns it an alias.
void UnloadMusic (const std::string & alias)
void UnloadSound (const std::string & alias)
void UnloadSprite (const std::string & alias)
Unloads a sprite and frees its resources.
AssetManager & operator= (const AssetManager &) = delete
AssetManager & operator= (AssetManager &&) = delete
~AssetManager ()

Public Functions Documentation

function AssetManager [⅓]

Engine::AssetManager::AssetManager () = default

function AssetManager [⅔]

Engine::AssetManager::AssetManager (
    const AssetManager &
) = delete

function AssetManager [3/3]

Engine::AssetManager::AssetManager (
    AssetManager &&
) = delete

function ClearAll

void Engine::AssetManager::ClearAll () 

function GetAllMusic

inline std::unordered_map< std::string, std::shared_ptr< Music > > & Engine::AssetManager::GetAllMusic () 

function GetAllSounds

inline std::unordered_map< std::string, std::shared_ptr< Sound > > & Engine::AssetManager::GetAllSounds () 

function GetFont

std::shared_ptr< raylib::Font > Engine::AssetManager::GetFont (
    const std::string & alias
) 

function GetMusic

std::shared_ptr< Music > Engine::AssetManager::GetMusic (
    const std::string & alias
) 

function GetSound

std::shared_ptr< Sound > Engine::AssetManager::GetSound (
    const std::string & alias
) 

function GetSprite

Retrieves a sprite by its alias.

std::shared_ptr< Sprite > Engine::AssetManager::GetSprite (
    const std::string & alias
) 

Parameters:

  • alias The unique identifier for the sprite.

Returns:

Reference to the Sprite object.

Exception:


function LoadFontFromMemory

void Engine::AssetManager::LoadFontFromMemory (
    const std::string & alias,
    const std::string & fileType,
    const unsigned char * fileData,
    int dataSize,
    int fontSize=12,
    int * fontChars=nullptr,
    int charsCount=0
) 

Parameters:

  • alias name to be used to retrieve this font
  • fileType Extension of the file like '.tff'
  • fileData the font file itself
  • dataSize the size of data to load
  • fontSize the base size of the font
  • fontChars In case we need to load more letters than ASCII like for example Ñ. If its nullptr it will load only ASCII
  • charsCount the number of elements to load from fontChars

function LoadMusic

Clears all loaded assets (sounds and sprites).

void Engine::AssetManager::LoadMusic (
    const std::string & alias,
    const std::string & filePath,
    bool isLoop=false
) 


function LoadMusicFromMemory

void Engine::AssetManager::LoadMusicFromMemory (
    const std::string & alias,
    const char * fileType,
    const unsigned char * data,
    int dataSize,
    bool isLoop=false
) 

function LoadSound

void Engine::AssetManager::LoadSound (
    const std::string & alias,
    const std::string & filePath,
    bool isLoop=false
) 

function LoadSoundFromMemory

void Engine::AssetManager::LoadSoundFromMemory (
    const std::string & alias,
    const char * fileType,
    const unsigned char * data,
    int dataSize,
    bool isLoop=false
) 

function LoadSprite

Loads a sprite texture from a file path and assigns it an alias.

void Engine::AssetManager::LoadSprite (
    const std::string & alias,
    const std::string & filePath
) 

Parameters:

  • alias The unique identifier for the sprite.
  • filePath The file path to the image file.

function UnloadMusic

void Engine::AssetManager::UnloadMusic (
    const std::string & alias
) 

function UnloadSound

void Engine::AssetManager::UnloadSound (
    const std::string & alias
) 

function UnloadSprite

Unloads a sprite and frees its resources.

void Engine::AssetManager::UnloadSprite (
    const std::string & alias
) 

Parameters:

  • alias The unique identifier for the sprite.

function operator=

AssetManager & Engine::AssetManager::operator= (
    const AssetManager &
) = delete

function operator=

AssetManager & Engine::AssetManager::operator= (
    AssetManager &&
) = delete

function ~AssetManager

inline Engine::AssetManager::~AssetManager () 


The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Assets/AssetManager.hpp