GEJM  1.0.0.0
a 2D platformer made by students
Trigger.h
1 #ifndef TRIGGER_H
2 #define TRIGGER_H
3 
4 #include "Game.h"
5 #include "SolidObject.h"
6 #include <functional>
7 
12 class Trigger :
13  public SolidObject
14 {
15 public:
30  Trigger(Game *const gameObject,
31  void (Game::*onTrigger)(),
32  void (Game::*onStartTouch)(),
33  void (Game::*onEndTouch)(),
34  double x = 0.0,
35  double y = 0.0,
36  double width = 3.0,
37  double height = 3.0,
38  bool triggerOnce = true);
39 
43  ~Trigger();
44 
48  void trigger();
49 
53  void untrigger();
54 
58  Trigger& operator=(Trigger const&) = delete;
59 private:
63  std::function<void(void)> onTrigger;
64 
68  std::function<void(void)> onStartTouch;
69 
73  std::function<void(void)> onEndTouch;
74 
78  bool const triggerOnce;
79 
83  bool isTriggered;
84 };
85 #endif // TRIGGER_H
double x
Definition: Object.h:83
double width
Definition: Object.h:93
double height
Definition: Object.h:98
double y
Definition: Object.h:88
~Trigger()
Definition: Trigger.cpp:48
void untrigger()
Definition: Trigger.cpp:79
Trigger(Game *const gameObject, void(Game::*onTrigger)(), void(Game::*onStartTouch)(), void(Game::*onEndTouch)(), double x=0.0, double y=0.0, double width=3.0, double height=3.0, bool triggerOnce=true)
Definition: Trigger.cpp:21
Definition: SolidObject.h:9
void trigger()
Definition: Trigger.cpp:55
Trigger & operator=(Trigger const &)=delete
Definition: Game.h:53
Definition: Trigger.h:12