Oxygine  1
2g game engine
SlidingActor.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Actor.h"
4 #include "math/Vector2.h"
5 #include "Draggable.h"
6 #include "ClipRectActor.h"
7 
8 namespace oxygine
9 {
10  DECLARE_SMART(SlidingActor, spSlidingActor);
11  class SlidingActor: public Actor
12  {
13  INHERITED(Actor);
14  public:
15  static void setDefaultTouchThreshold(float val);
16 
17  class SlidingEvent: public Event
18  {
19  public:
20  enum SEvent
21  {
22  BEGIN = sysEventID('S', 'B', 'G'),
23  SLIDING = sysEventID('S', 'S', 'L'),
24  END = sysEventID('S', 'E', 'N')
25  };
26 
27  SlidingEvent(SEvent ev) : Event(ev) {}
28  Vector2 speed;
29  };
30 
31 
32  SlidingActor();
33  ~SlidingActor();
34 
35  spActor getContent() const {return _content;}
36  const RectF& getDragBounds() const {return _drag.getDragBounds();}
37 
39  void setTouchThreshold(float rad);
41  void setContent(spActor content);
43  void setLocked(bool locked);
45  void snap();
47  void stop();
48 
49  void serialize(serializedata* data) override;
50  void deserialize(const deserializedata* data) override;
51 
52  protected:
53  void destroy();
54 
55  void handleEvent(Event* event) override;
56  void sizeChanged(const Vector2& size) override;
57  void doUpdate(const UpdateState& us) override;
58  void updateDragBounds();
59 
60 
61  void _newEvent(Event* event);
62 
63  bool _sliding;
64  float _rad;
65  float _maxSpeed;
66  timeMS _downTime;
67 
68  Vector2 _downPos;
69  Vector2 _speed;
70 
71  Draggable _drag;
72 
73  spActor _content;
74  spClipRectActor _clip;
75 
76  spEventDispatcher _holded;
77 
78  struct iter
79  {
80  Vector2 pos;
81  timeMS tm;
82  };
83 
84  timeMS _lastTime;
85  enum {NUM = 11};
86  iter _prev[NUM];
87  int _current;
88 
89  timeMS _lastIterTime;
90  pointer_index _finger;
91 
92  bool _ignoreTouchUp;
93  };
94 }
95 
96 EDITOR_INCLUDE(SlidingActor);
Definition: Actor.h:42
Definition: Event.h:10
void setContent(spActor content)
void setLocked(bool locked)
–oxgl-end–!
Definition: Actor.h:14
void doUpdate(const UpdateState &us) override
Definition: SlidingActor.h:17
void setTouchThreshold(float rad)
Definition: SlidingActor.h:78
Definition: SlidingActor.h:11