![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CULoadingScene.h>
Public Member Functions | |
| LoadingScene () | |
| ~LoadingScene () | |
| void | dispose () |
| bool | init (const std::string scene, const std::string directory) |
| bool | init (const std::shared_ptr< cugl::AssetManager > &manager, const std::string directory) |
| std::shared_ptr< cugl::AssetManager > | getAssetManager () const |
| void | start () |
| void | update (float timestep) |
| float | getProgress () const |
| bool | isPending () const |
| bool | isComplete () const |
Public Member Functions inherited from cugl::scene2::Scene2 | |
| Scene2 () | |
| ~Scene2 () | |
| virtual void | dispose () override |
| virtual bool | init () override |
| virtual bool | initWithHint (Size hint) override |
| virtual bool | initWithHint (float width, float height) override |
| Color4 | getColor () |
| void | setColor (Color4 color) |
| virtual std::string | toString (bool verbose=false) const override |
| size_t | getChildCount () const |
| std::shared_ptr< scene2::SceneNode > | getChild (unsigned int pos) |
| const std::shared_ptr< scene2::SceneNode > & | getChild (unsigned int pos) const |
| template<typename T > | |
| std::shared_ptr< T > | getChild (unsigned int pos) const |
| std::shared_ptr< scene2::SceneNode > | getChildByTag (unsigned int tag) const |
| template<typename T > | |
| std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
| std::shared_ptr< scene2::SceneNode > | getChildByName (const std::string name) const |
| template<typename T > | |
| std::shared_ptr< T > | getChildByName (const std::string name) const |
| std::vector< std::shared_ptr< scene2::SceneNode > > | getChildren () |
| const std::vector< std::shared_ptr< scene2::SceneNode > > & | getChildren () const |
| virtual void | addChild (const std::shared_ptr< scene2::SceneNode > &child) |
| void | addChildWithTag (const std::shared_ptr< scene2::SceneNode > &child, unsigned int tag) |
| void | addChildWithName (const std::shared_ptr< scene2::SceneNode > &child, const std::string name) |
| void | swapChild (const std::shared_ptr< scene2::SceneNode > &child1, const std::shared_ptr< scene2::SceneNode > &child2, bool inherit=false) |
| virtual void | removeChild (unsigned int pos) |
| void | removeChild (const std::shared_ptr< scene2::SceneNode > &child) |
| void | removeChildByTag (unsigned int tag) |
| void | removeChildByName (const std::string name) |
| virtual void | removeAllChildren () |
| std::shared_ptr< graphics::SpriteBatch > | getSpriteBatch () const |
| void | setSpriteBatch (const std::shared_ptr< graphics::SpriteBatch > &batch) |
| virtual void | render () override |
Public Member Functions inherited from cugl::Scene | |
| Scene () | |
| ~Scene () | |
| virtual void | dispose () |
| virtual bool | init () |
| virtual bool | initWithHint (Size hint) |
| virtual bool | initWithHint (float width, float height) |
| const std::string | getName () const |
| void | setName (const std::string name) |
| std::shared_ptr< Camera > | getCamera () |
| const std::shared_ptr< Camera > | getCamera () const |
| virtual std::string | toString (bool verbose=false) const |
| operator std::string () const | |
| const Size | getSize () const |
| const Rect | getBounds () const |
| Vec3 | screenToWorldCoords (const Vec2 screenCoords) const |
| Vec2 | worldToScreenCoords (const Vec3 worldCoords) const |
| bool | isActive () const |
| virtual void | setActive (bool value) |
| virtual void | update (float timestep) |
| virtual void | reset () |
| virtual void | render () |
Static Public Member Functions | |
| static std::shared_ptr< LoadingScene > | alloc (const std::string scene, const std::string directory) |
| static std::shared_ptr< LoadingScene > | alloc (const std::shared_ptr< cugl::AssetManager > &manager, const std::string directory) |
Static Public Member Functions inherited from cugl::scene2::Scene2 | |
| static std::shared_ptr< Scene2 > | alloc () |
| static std::shared_ptr< Scene2 > | allocWithHint (const Size hint) |
| static std::shared_ptr< Scene2 > | allocWithHint (float width, float height) |
Protected Attributes | |
| std::shared_ptr< cugl::AssetManager > | _assets |
| std::string | _directory |
| std::shared_ptr< cugl::scene2::SceneNode > | _before |
| std::shared_ptr< cugl::scene2::SceneNode > | _after |
| std::shared_ptr< cugl::scene2::Button > | _button |
| std::shared_ptr< cugl::scene2::ProgressBar > | _bar |
| float | _progress |
| bool | _completed |
| bool | _started |
Protected Attributes inherited from cugl::scene2::Scene2 | |
| std::shared_ptr< graphics::SpriteBatch > | _batch |
| std::vector< std::shared_ptr< scene2::SceneNode > > | _children |
| Color4 | _color |
| GLenum | _blendEquation |
| GLenum | _srcFactor |
| GLenum | _dstFactor |
Protected Attributes inherited from cugl::Scene | |
| std::shared_ptr< Camera > | _camera |
| std::string | _name |
| Size | _size |
| bool | _active |
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.
|
inline |
Creates a new loading scene with the default values.
This constructor does not allocate any objects or start the scene. This allows us to use the object without a heap pointer.
|
inline |
Deletes this scene, disposing all resources.
|
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.
| manager | A previously initialized asset manager |
| directory | The asset directory to load asynchronously |
|
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.
| scene | A JSON file with the scene graph for this scene |
| directory | The asset directory to load asynchronously |
|
virtual |
Disposes all of the resources used by this sceene.
A disposed node can be safely reinitialized. The scene graph owned by this scene will be released, as well as the asset manager. They will be deleted if no other object owns them.
Reimplemented from cugl::scene2::Scene2.
|
inline |
Returns the asset manager for this loading scene
|
inline |
Returns the current progress of this this loading scene.
The value is in the range [0,1] where 0 means no progress and 1 means that loading has completed.
| 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.
| manager | A previously initialized asset manager |
| directory | The asset directory to load asynchronously |
| 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.
| scene | A JSON file with the scene graph for this scene |
| directory | The asset directory to load asynchronously |
|
inline |
Returns true if loading is complete, and the player has pressed play
|
inline |
Returns true if loading is complete, but the player has not pressed play
| void cugl::scene2::LoadingScene::start | ( | ) |
Starts the loading progress for this scene
This method has no affect if loading is already in progress.
|
virtual |
Updates the loading scene progress.
This method queries the asset manager to update the progress bar amount.
| timestep | The amount of time (in seconds) since the last frame |
Reimplemented from cugl::Scene.
|
protected |
The scene during when complete
|
protected |
The asset manager for loading.
|
protected |
The animated progress bar
|
protected |
The scene during loading
|
protected |
The "play" button
|
protected |
Whether or not the player has pressed play to continue
|
protected |
The asset directory reference
|
protected |
The progress displayed on the screen
|
protected |
Whether or not the asset loader has started loading