123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- #ifndef __CC_TOUCH_H__
- #define __CC_TOUCH_H__
- #include "base/CCRef.h"
- #include "math/CCGeometry.h"
- NS_CC_BEGIN
- class CC_DLL Touch : public Ref
- {
- public:
-
- enum class DispatchMode {
- ALL_AT_ONCE,
- ONE_BY_ONE,
- };
-
- Touch()
- : _id(0),
- _startPointCaptured(false),
- _curForce(0.f),
- _maxForce(0.f)
- {}
-
- Vec2 getLocation() const;
-
- Vec2 getPreviousLocation() const;
-
- Vec2 getStartLocation() const;
-
- Vec2 getDelta() const;
-
- Vec2 getLocationInView() const;
-
- Vec2 getPreviousLocationInView() const;
-
- Vec2 getStartLocationInView() const;
-
-
- void setTouchInfo(int id, float x, float y)
- {
- _id = id;
- _prevPoint = _point;
- _point.x = x;
- _point.y = y;
- _curForce = 0.0f;
- _maxForce = 0.0f;
- if (!_startPointCaptured)
- {
- _startPoint = _point;
- _startPointCaptured = true;
- _prevPoint = _point;
- }
- }
-
- void setTouchInfo(int id, float x, float y, float force, float maxForce)
- {
- _id = id;
- _prevPoint = _point;
- _point.x = x;
- _point.y = y;
- _curForce = force;
- _maxForce = maxForce;
- if (!_startPointCaptured)
- {
- _startPoint = _point;
- _startPointCaptured = true;
- _prevPoint = _point;
- }
- }
-
- int getID() const
- {
- return _id;
- }
-
- float getCurrentForce() const;
-
- float getMaxForce() const;
- private:
- int _id;
- bool _startPointCaptured;
- Vec2 _startPoint;
- Vec2 _point;
- Vec2 _prevPoint;
- float _curForce;
- float _maxForce;
- };
- NS_CC_END
- #endif
|