-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFPSService.cpp
More file actions
62 lines (50 loc) · 1.02 KB
/
Copy pathFPSService.cpp
File metadata and controls
62 lines (50 loc) · 1.02 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
52
53
54
55
56
57
58
59
60
61
62
#include "FPSService.h"
#include "getTimer.h"
FPSService::FPSService()
{
fps = 0;
frameTime = 0.;
}
void FPSService::start()
{
//this->setFps(dispay.stage.frameRate);
//dispay.stage.addEventListener(Event.ENTER_FRAME, this->onEnterFrame);
//dispay.stage.addEventListener(Event.DEACTIVATE, this->onDeactivate);
this->deactiave = false;
this->starting = true;
}
void FPSService::onEnterFrame()
{
if (this->deactiave)
{
return;
}
if (this->starting)
{
this->lastTime = getTimer();
this->numFrames = 0;
this->starting = false;
return;
}
int _local_2 = getTimer();
this->numFrames++;
if ((_local_2 - this->lastTime) > 2000)
{
this->setFps((1000 * this->numFrames) / (_local_2 - this->lastTime));
this->lastTime = _local_2;
this->numFrames = 0;
}
}
void FPSService::setFps(int v)
{
this->fps = v;
this->frameTime = (1000. / v);
}
int FPSService::getFps()
{
return this->fps;
}
double FPSService::getFrameTimeMS()
{
return this->frameTime;
}