-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.cpp
More file actions
51 lines (45 loc) · 1.01 KB
/
scene.cpp
File metadata and controls
51 lines (45 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "scene.h"
Scene::Scene()
{
this->sceneLock = new std::mutex();
Object* obj = new Object();
this->rootObject = obj;
obj->rootObject = obj;
obj->setTag("root");
this->lastUpdateTime = sf::Clock();
}
Object* Scene::createObject(Object* parentObj)
{
Object* obj = new Object();
obj->setParent(parentObj);
obj->rootObject = this->rootObject;
return obj;
}
Object* Scene::createObject()
{
Object* obj = new Object();
obj->setParent(this->rootObject);
return obj;
}
Object* Scene::getObjectByTag(std::string tag)
{
Object* obj = this->findRecursively(tag, this->rootObject);
return obj;
}
Object* Scene::findRecursively(std::string tag, Object* obj)
{
for (Object* childObj : obj->getChilds())
{
if (tag == childObj->getTag())
{
return childObj;
}
else
{
if (childObj->getChilds().size() != 0)
{
this->findRecursively(tag, childObj);
}
}
}
}