-
Notifications
You must be signed in to change notification settings - Fork 13
/
SneakyJoystick.h
47 lines (38 loc) · 1.51 KB
/
SneakyJoystick.h
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
#ifndef __SNEAKY_JOYSTICK_H__
#define __SNEAKY_JOYSTICK_H__
#include "cocos2d.h"
class SneakyJoystick : public cocos2d::CCNode, public cocos2d::CCTargetedTouchDelegate
{
protected:
float joystickRadiusSq;
float thumbRadiusSq;
float deadRadiusSq;
CC_SYNTHESIZE_READONLY(cocos2d::CCPoint, stickPosition, StickPosition);
CC_SYNTHESIZE_READONLY(float, degrees, Degrees);
CC_SYNTHESIZE_READONLY(cocos2d::CCPoint, velocity, Velocity);
CC_SYNTHESIZE(bool, autoCenter, AutoCenter);
CC_SYNTHESIZE_READONLY(bool, isDPad, IsDPad);
CC_SYNTHESIZE(bool, hasDeadzone, HasDeadzone);
CC_SYNTHESIZE(int, numberOfDirections, NumberOfDirections);
CC_SYNTHESIZE_READONLY(float, joystickRadius, JoystickRadius);
CC_SYNTHESIZE_READONLY(float, thumbRadius, ThumbRadius);
CC_SYNTHESIZE_READONLY(float, deadRadius, DeadRadius);
virtual ~SneakyJoystick();
bool initWithRect(cocos2d::CCRect rect);
virtual void onEnterTransitionDidFinish();
virtual void onExit();
void setIsDPad(bool b);
void setJoystickRadius(float r);
void setThumbRadius(float r);
void setDeadRadius(float r);
virtual bool ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event);
virtual void ccTouchMoved(cocos2d::CCTouch *touch, cocos2d::CCEvent *event);
virtual void ccTouchEnded(cocos2d::CCTouch *touch, cocos2d::CCEvent *event);
virtual void ccTouchCancelled(cocos2d::CCTouch *touch, cocos2d::CCEvent *event);
void touchDelegateRelease();
void touchDelegateRetain();
private:
void updateVelocity(cocos2d::CCPoint point);
void setTouchRadius();
};
#endif