Kiwano Engine v1.3.x
Timer.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/core/Time.h>
23#include <kiwano/base/ObjectBase.h>
24
25namespace kiwano
26{
27
30class KGE_API Timer : public ObjectBase
31{
32public:
33 Timer();
34
35 virtual ~Timer();
36
39 Duration GetDeltaTime() const;
40
43 Duration GetTotalTime() const;
44
47 bool IsPausing() const;
48
51 void Tick();
52
55 void Resume();
56
59 void Pause();
60
63 void Reset();
64
65private:
66 bool is_paused_;
67 Time start_time_;
68 Time paused_time_;
69 Time current_time_;
70 Time previous_time_;
71 Duration delta_time_;
72 Duration total_idle_time_;
73};
74
75} // namespace kiwano
基础对象
Definition: ObjectBase.h:138
计时器
Definition: Timer.h:31
时间段
Definition: Duration.h:48
时间
Definition: Time.h:42