-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.h
57 lines (49 loc) · 1.12 KB
/
Scene.h
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
52
53
54
55
56
57
#pragma once
#ifndef SCENE_H
#define SCENE_H
#include <iostream>
#include <string>
#include <map>
#include <SDL.h>
#include "Node.h"
#include "Timer.h"
#include "Polygon.h"
#include "Grid.h"
class Scene {
protected:
Node rootNode;
//map<string, Node*> childen;
const int SCREEN_FPS = 60;
const int SCREEN_TICKS_PER_FRAME = 1000 / SCREEN_FPS;
//每秒钟定时器的帧数
LTimer fpsTimer;
//每秒帧数上限定时器
LTimer capTimer;
int frameTicks;
public:
bool isEnd = false;
//Game* game = NULL;
public:
Scene()
: isEnd(false), frameTicks(0) {
rootNode = Node();
rootNode.rootScene = this;
rootNode.name = "root";
rootNode.parent = NULL;
};
//virtual vector<Node*> getAllChildren();
//virtual void addChild(string name, Node* n);
virtual void onLoad();
virtual void onLoad(Vec2 playerPosition) { onLoad(); };
virtual void onExit();
virtual void onUpdate(double dt);
virtual void reset() {};
virtual void draw();
virtual void setRootNode(Node node) {
rootNode = node;
}
virtual void addChild(string name, Node* n);
virtual vector<Node*> getAllChildren();
virtual vector<Polygon2D*> getAllCollider();
};
#endif