JNGL
Easy to use cross-platform 2D game library
|
Use this class to load a Sprite asynchronously. More...
#include <jngl/sprite.hpp>
Public Member Functions | |
Loader (std::string filename) noexcept | |
Starts a thread to load filename and returns instantly. | |
~Loader () noexcept | |
Blocks until the Sprite has been loaded. | |
std::shared_ptr< Sprite > | shared () const |
Blocks until the Sprite has been loaded and returns a non-nullptr std::shared_ptr. | |
operator bool () const | |
Returns whether the sprite has been loaded, does NOT block. | |
Sprite * | operator-> () const |
Blocks until the Sprite has been loaded. | |
Use this class to load a Sprite asynchronously.
Example:
Definition at line 84 of file sprite.hpp.
|
explicitnoexcept |
Starts a thread to load filename and returns instantly.
Note that if the file couldn't be found this will not throw. Instead the exception will be thrown on first use by shared() or operator->().
|
noexcept |
Blocks until the Sprite has been loaded.
While you won't have access to std::shared_ptr returned by shared(), the Sprite will still be loaded into JNGL's cache and the next time you create a Sprite from this filename, you'll get the same std::shared_ptr.
If shared() or operator->() haven't been called yet and the file wasn't found the destructor won't throw but use errorMessage(const std::string&).
std::shared_ptr< Sprite > shared | ( | ) | const |
Blocks until the Sprite has been loaded and returns a non-nullptr std::shared_ptr.
std::runtime_error | on decoding errors or file not found |
operator bool | ( | ) | const |
Returns whether the sprite has been loaded, does NOT block.
After this returned true all other methods won't block any more.
Sprite * operator-> | ( | ) | const |
Blocks until the Sprite has been loaded.
std::runtime_error | on decoding errors or file not found |