This class is a simple loading screen for asychronous asset loading.
This class will either create its own AssetManager
, or it can be assigned on. In the latter case, it needs a json file defining the assets for the initial loading screen. In the former, the asset manager should come preloaded with these assets. To properly display to the screen, these assets must include a scene2::SceneNode
named "load". This node must have at least four children:
- "load.before": The scene to display while loading is in progress
- "load.after": The scene to display when the loading is complete
- "load.bar": A {@link ProgressBar} for showing the loading progress
- "load.play" A play {@link Button} for the user to start the game
When the play button is pressed, this scene is deactivated, indicating to the application that it is time to switch scenes.
In addition to these assets, the loading scene will take the take of an asset directory. This is a JSON file defining the assets that should be loaded asynchronously by this loading scene. Accessing the asset manager with getAssetManager
gives access to these assets.
static std::shared_ptr< LoadingScene > cugl::scene2::LoadingScene::alloc |
( |
const std::shared_ptr< cugl::AssetManager > & |
manager, |
|
|
const std::string |
directory |
|
) |
| |
|
inlinestatic |
Returns a newly allocated loading scene with the given asset manager and directory.
The asset manager must already contain the scene graph used by this scene. The scene must include a scene2::SceneNode
named "load". This node must have at least four children:
- "load.before": The scene to display while loading is in progress
- "load.after": The scene to display when the loading is complete
- "load.bar": A {@link ProgressBar} for showing the loading progress
- "load.play" A play {@link Button} for the user to start the game
The string directory is the asset directory to be loaded asynchronously by this scene. The progress on this directory can be monitored via getProgress
.
- Parameters
-
manager | A previously initialized asset manager |
directory | The asset directory to load asynchronously |
- Returns
- a newly allocated loading scene with the given asset manager and directory.
static std::shared_ptr< LoadingScene > cugl::scene2::LoadingScene::alloc |
( |
const std::string |
scene, |
|
|
const std::string |
directory |
|
) |
| |
|
inlinestatic |
Returns a newly allocated loading scene with the given scene and directory.
This class will create its own AssetManager
, which can be accessed via getAssetManager
. This asset manager will only attach loaders for graphics::Font
, graphics::Texture
, scene2::SceneNode
and WidgetValue
.
The string scene should be a path to a JSON file that defines the scene graph for this loading scene. This file will be loaded synchronously, so it should be lightweight. The scene must include a scene2::SceneNode
named "load". This node must have at least four children:
- "load.before": The scene to display while loading is in progress
- "load.after": The scene to display when the loading is complete
- "load.bar": A {@link ProgressBar} for showing the loading progress
- "load.play" A play {@link Button} for the user to start the game
The string directory is the asset directory to be loaded asynchronously by this scene. The progress on this directory can be monitored via getProgress
.
- Parameters
-
scene | A JSON file with the scene graph for this scene |
directory | The asset directory to load asynchronously |
- Returns
- a newly allocated loading scene with the given scene and directory.
bool cugl::scene2::LoadingScene::init |
( |
const std::shared_ptr< cugl::AssetManager > & |
manager, |
|
|
const std::string |
directory |
|
) |
| |
Initializes a loading scene with the given asset manager and directory.
The asset manager must already contain the scene graph used by this scene. The scene must include a scene2::SceneNode
named "load". This node must have at least four children:
- "load.before": The scene to display while loading is in progress
- "load.after": The scene to display when the loading is complete
- "load.bar": A {@link ProgressBar} for showing the loading progress
- "load.play" A play {@link Button} for the user to start the game
The string directory is the asset directory to be loaded asynchronously by this scene. The progress on this directory can be monitored via getProgress
.
- Parameters
-
manager | A previously initialized asset manager |
directory | The asset directory to load asynchronously |
- Returns
- true if the scene is initialized properly, false otherwise.
bool cugl::scene2::LoadingScene::init |
( |
const std::string |
scene, |
|
|
const std::string |
directory |
|
) |
| |
Initializes a loading scene with the given scene and directory.
This class will create its own AssetManager
, which can be accessed via getAssetManager
. This asset manager will only attach loaders for graphics::Font
, graphics::Texture
, scene2::SceneNode
and WidgetValue
.
The string scene should be a path to a JSON file that defines the scene graph for this loading scene. This file will be loaded synchronously, so it should be lightweight. The scene must include a scene2::SceneNode
named "load". This node must have at least four children:
- "load.before": The scene to display while loading is in progress
- "load.after": The scene to display when the loading is complete
- "load.bar": A {@link ProgressBar} for showing the loading progress
- "load.play" A play {@link Button} for the user to start the game
The string directory is the asset directory to be loaded asynchronously by this scene. The progress on this directory can be monitored via getProgress
.
- Parameters
-
scene | A JSON file with the scene graph for this scene |
directory | The asset directory to load asynchronously |
- Returns
- true if the scene is initialized properly, false otherwise.