HalloweenSimpleButton.h
2.05 KB
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
48
49
50
51
52
53
54
55
//
// HalloweenSimpleButton.h
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//
#ifndef HalloweenSimpleButton_h
#define HalloweenSimpleButton_h
#include "HLayoutObject.h"
#include "ui/CocosGUI.h"
class HalloweenSimpleButton : public cocos2d::ui::Button, public HLayoutObject
{
public:
struct ButtonActionData {
std::function<void()> onTouchBegan;
std::function<void()> onTouchEnded;
std::function<void()> onTouchCancelled;
};
static HalloweenSimpleButton* create();
virtual bool init() override;
virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, HLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") override;
virtual void prepareSize(const rapidjson::Value& jsonValue, float& width, float& height) override;
virtual bool isWidget() override;
virtual void setOnTouchBeganCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback) override;
virtual void setOnTouchEndedCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback) override;
virtual void setOnTouchCancelledCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback) override;
virtual void setOriginalScale(float scale);
virtual float getOriginalScale();
virtual void imitateTouchDown();
virtual void imitateTouchUp();
protected:
float _originalScale;
bool _adjustScaleOnPress;
std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> _touchBeganCallback;
std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> _touchEndedCallback;
std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> _touchCancelledCallback;
ButtonActionData _buttonOwnTouchBehaviour;
virtual void configureTouchListeners();
};
#endif /* HalloweenSimpleButton_h */