NWengine 0.9
Loading...
Searching...
No Matches
Scene.h
1#pragma once
2#include "GameObject.h"
3#include "Sprite.h"
4#include<list>
5
9class Scene {
10public:
11 bool _shouldDelObj = 0;
13 std::string name;
14 std::list<GameObject> sceneObjs;
15 std::list<Sprite*> drawList;
22
27 void DeleteObject(uint32 index);
28
33 void DeleteObject(std::string name);
34
40 std::list<GameObject>::iterator DeleteObject(std::list<GameObject>::iterator it);
41
46 void DeleteCurrentObj();
47
48
54 GameObject* GetGameObject(std::string name);
55
61 GameObject* GetGameObject(const uint32& position);
62
68
73 void SortScene();
74
79 void Render(Sprite* sprite);
80
85 void ForceRenderStop();
86
92 void Rearrange(Sprite* sprite);
93
101 const std::string& Rename(const std::string& newName, GameObject* obj);
102
107 Scene(const std::string& path);
108
112 ~Scene();
113
117 void LoadScene();
118
123 void MakeCurrent();
124
129 bool IsCurrent();
130
135 void Start();
136
142 void Update();
143
147 void SetUp();
148
153 void Draw();
154
158 void Save();
159
165 void SetPath(const std::string& path);
166
172 static Scene& CreateNew(const std::string& path);
173
180 static Scene* GetScene(const std::string& path);
181
187 static bool DeleteScene(const std::string& path);
188
192 static void Destroy();
193
197 static void UpdateActiveScene();
198
203 static Scene* GetCurrent();
204
205 static std::list<Scene> _scenes;
207};
Defines the GameObject class and its related components.
Defines the Sprite class, which represents a game sprite.
Class representing a game object.
Definition GameObject.h:68
Represents a scene in the game.
Definition Scene.h:9
static Scene & CreateNew(const std::string &path)
Creates a new scene and pushes it to a container.
Definition Scene.cpp:279
std::list< GameObject > sceneObjs
Definition Scene.h:14
void SortScene()
Deprecated. Sorts the scene objects container. This method is no longer used as objects are kept sort...
Definition Scene.cpp:18
bool _shouldDelObj
Definition Scene.h:11
void Start()
Initializes the scene. This method should be called once before the update.
Definition Scene.cpp:216
~Scene()
Destroys the Scene object.
Definition Scene.cpp:208
void SetUp()
Sets up the needed static variables and other things.
Definition Scene.cpp:263
std::string name
Definition Scene.h:13
bool IsCurrent()
Checks if the scene is the current scene.
Definition Scene.cpp:203
void Draw()
Draws all the scene objects. This method is called within the default NWengine update.
Definition Scene.cpp:126
Scene(const std::string &path)
Constructs a Scene object with the given path.
Definition Scene.cpp:13
void Render(Sprite *sprite)
Adds a sprite to the draw list.
Definition Scene.cpp:31
static Scene * currentScene
Definition Scene.h:206
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 det...
Definition Scene.cpp:284
GameObject & AddObject()
Adds a new empty GameObject to the scene objects container.
Definition Scene.cpp:83
void ForceRenderStop()
Iterates over the draw list and deletes sprites that are not rendered. If a sprite is not rendered,...
Definition Scene.cpp:59
void DeleteObject(uint32 index)
Deletes a GameObject from the scene objects container by index.
Definition Scene.cpp:97
void Update()
Updates the scene. This method should be called every frame. It is called within the default NWengine...
Definition Scene.cpp:224
static Scene * GetCurrent()
Gets the current scene.
Definition Scene.cpp:308
void Rearrange(Sprite *sprite)
Refinds a position to insert a sprite in the draw list. This method is called internally when the lay...
Definition Scene.cpp:20
GameObject * GetGameObject()
Gets the last object added to the scene.
Definition Scene.cpp:78
void DeleteCurrentObj()
This function is intended to be called within object (to-delete) component (like scripts),...
Definition Scene.cpp:114
void MakeCurrent()
Sets the scene as the current scene. The current scene will be updated and drawn during the engine up...
Definition Scene.cpp:199
static bool DeleteScene(const std::string &path)
Deletes a scene by its path.
Definition Scene.cpp:294
void SetPath(const std::string &path)
Sets the path of the scene. This method changes the "name" member to the given path.
Definition Scene.cpp:274
static void UpdateActiveScene()
Updates the active scene.
Definition Scene.cpp:313
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...
Definition Scene.cpp:240
void LoadScene()
Loads the scene from the file with the same name as the path.
Definition Scene.cpp:165
static void Destroy()
Destroys the current scene.
Definition Scene.cpp:304
static std::list< Scene > _scenes
Definition Scene.h:205
void Save()
Serializes the scene and saves it in a file with the same name.
Definition Scene.cpp:155
std::list< Sprite * > drawList
Definition Scene.h:15
Represents a game sprite.
Definition Sprite.h:26