|
NWengine 0.9
|
Represents a scene in the game. More...
#include <Scene.h>
Public Member Functions | |
| GameObject & | AddObject () |
| Adds a new empty GameObject to the scene objects container. | |
| void | DeleteObject (uint32 index) |
| Deletes a GameObject from the scene objects container by index. | |
| void | DeleteObject (std::string name) |
| Deletes a GameObject from the scene objects container by name. | |
| std::list< GameObject >::iterator | DeleteObject (std::list< GameObject >::iterator it) |
| Deletes a GameObject from the scene objects container by iterator. | |
| void | DeleteCurrentObj () |
| This function is intended to be called within object (to-delete) component (like scripts), as DeleteObject() will produce invalidation internally. | |
| GameObject * | GetGameObject (std::string name) |
| Gets a GameObject in the scene by name. | |
| GameObject * | GetGameObject (const uint32 &position) |
| Gets a GameObject in the scene by position. | |
| GameObject * | GetGameObject () |
| Gets the last object added to the scene. | |
| void | SortScene () |
| Deprecated. Sorts the scene objects container. This method is no longer used as objects are kept sorted at each insertion. | |
| void | Render (Sprite *sprite) |
| Adds a sprite to the draw list. | |
| void | ForceRenderStop () |
| Iterates over the draw list and deletes sprites that are not rendered. If a sprite is not rendered, it will be deleted. Otherwise, the action is taken only at the next scene draw. | |
| void | Rearrange (Sprite *sprite) |
| Refinds a position to insert a sprite in the draw list. This method is called internally when the layer of a sprite changes. | |
| const std::string & | Rename (const std::string &newName, GameObject *obj) |
| Renames a GameObject. This method is mostly used internally and can be used by the user to change the name of an object. | |
| Scene (const std::string &path) | |
| Constructs a Scene object with the given path. | |
| ~Scene () | |
| Destroys the Scene object. | |
| void | LoadScene () |
| Loads the scene from the file with the same name as the path. | |
| void | MakeCurrent () |
| Sets the scene as the current scene. The current scene will be updated and drawn during the engine update. | |
| bool | IsCurrent () |
| Checks if the scene is the current scene. | |
| void | Start () |
| Initializes the scene. This method should be called once before the update. | |
| void | Update () |
| Updates the scene. This method should be called every frame. It is called within the default NWengine update. | |
| void | SetUp () |
| Sets up the needed static variables and other things. | |
| void | Draw () |
| Draws all the scene objects. This method is called within the default NWengine update. | |
| void | Save () |
| Serializes the scene and saves it in a file with the same name. | |
| void | SetPath (const std::string &path) |
| Sets the path of the scene. This method changes the "name" member to the given path. | |
Static Public Member Functions | |
| static Scene & | CreateNew (const std::string &path) |
| Creates a new scene and pushes it to a container. | |
| static Scene * | GetScene (const std::string &path) |
| Gets a scene by its path. If multiple scenes have the same path, it returns one of them; order or determinism is not guaranteed. | |
| static bool | DeleteScene (const std::string &path) |
| Deletes a scene by its path. | |
| static void | Destroy () |
| Destroys the current scene. | |
| static void | UpdateActiveScene () |
| Updates the active scene. | |
| static Scene * | GetCurrent () |
| Gets the current scene. | |
Public Attributes | |
| bool | _shouldDelObj = 0 |
| std::string | name |
| std::list< GameObject > | sceneObjs |
| std::list< Sprite * > | drawList |
Static Public Attributes | |
| static std::list< Scene > | _scenes |
| static Scene * | currentScene = nullptr |
Represents a scene in the game.
| Scene::Scene | ( | const std::string & | path | ) |
Constructs a Scene object with the given path.
| path | The path of the scene file. |
| GameObject &const Scene::AddObject | ( | ) |
Adds a new empty GameObject to the scene objects container.
Creates a new scene and pushes it to a container.
| path | The path of the new scene. |
| std::list< GameObject >::iterator Scene::DeleteObject | ( | std::list< GameObject >::iterator | it | ) |
Deletes a GameObject from the scene objects container by iterator.
| it | The iterator of the object to delete. |
| void Scene::DeleteObject | ( | std::string | name | ) |
Deletes a GameObject from the scene objects container by name.
| name | The name of the GameObject to delete. |
| void Scene::DeleteObject | ( | uint32 | index | ) |
Deletes a GameObject from the scene objects container by index.
| index | The index of the GameObject to delete. |
Deletes a scene by its path.
| path | The path of the scene to delete. |
|
static |
Gets the current scene.
| GameObject * Scene::GetGameObject | ( | ) |
Gets the last object added to the scene.
| GameObject * Scene::GetGameObject | ( | const uint32 & | position | ) |
Gets a GameObject in the scene by position.
| position | The position of the GameObject to get. |
| GameObject * Scene::GetGameObject | ( | std::string | name | ) |
Gets a GameObject in the scene by name.
| name | The name of the GameObject to get. |
Gets a scene by its path. If multiple scenes have the same path, it returns one of them; order or determinism is not guaranteed.
| path | The path of the scene. |
| bool Scene::IsCurrent | ( | ) |
Checks if the scene is the current scene.
Refinds a position to insert a sprite in the draw list. This method is called internally when the layer of a sprite changes.
| sprite | The sprite to rearrange. |
| const std::string & Scene::Rename | ( | const std::string & | newName, |
| GameObject * | obj ) |
Renames a GameObject. This method is mostly used internally and can be used by the user to change the name of an object.
| newName | The new name for the GameObject. |
| obj | The GameObject to rename. |
Adds a sprite to the draw list.
| sprite | The sprite to add. |
Sets the path of the scene. This method changes the "name" member to the given path.
| path | The new path for the scene. |
|
static |
The list of all scenes.
| bool Scene::_shouldDelObj = 0 |
Internal flag that holds if currently iterated on gameobject during update should be deleted. see DestroyCurrentObj() for details
| std::list<Sprite*> Scene::drawList |
The list of sprites to be drawn in the scene.
| std::string Scene::name |
The name of the scene.
| std::list<GameObject> Scene::sceneObjs |
The list of game objects in the scene.