Module macroquad::experimental::collections::storage
source · [−]Expand description
Global persistent storage. Nice for some global game configs available everywhere. Yes, singletons available right here, with a nice API and some safety. Global read-only storage
use macroquad::experimental::collections::storage;
struct WorldBoundaries(i32);
fn draw_player() {
let boundaries: i32 = storage::get::<WorldBoundaries>().0;
assert_eq!(boundaries, 23);
}
storage::store(WorldBoundaries(23));
draw_player();
Functions
Get reference to data from global storage. Will panic if there is no data available with this type.
Get mutable reference to data from global storage. Will panic if there is no data available with this type.
Store data in global storage. Will silently overwrite an old value if any.
Get reference to data from global storage. Will return None if there is no data available with this type.
Get mutable reference to data from global storage. Will return None if there is no data available with this type.