ToyPaletteComponentSprite.h
2.27 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
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// ToyPaletteComponentSprite.h
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//
#ifndef ToyPaletteComponentSprite_h
#define ToyPaletteComponentSprite_h
#include "ToyPlainSprite.h"
class ToyPaletteComponentSprite : public ToyPlainSprite
{
public:
static ToyPaletteComponentSprite* createWithFile(std::string filePath, bool swallowTouches = false);
virtual bool initWithFile(std::string filePath, bool swallowTouches = false);
virtual bool isChosen();
virtual bool setChosen(bool chosen, bool animated = false, bool silent = false, bool notifyParentPalette = true);
virtual void setEnabled(bool isEnabled, bool adjustOpacity, bool animated);
virtual cocos2d::Rect getTouchArea(); //warning: only good fo anchor point 0.5,0.5
virtual cocos2d::Color3B getColour();
virtual float getBrushSize();
virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, ToyLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") override;
// virtual void onEnter() override;
//ToyScenarioObject
virtual void setProperty(std::string propertyName, const rapidjson::Value& newValue, ActionParseDelegate* parseDelegate) override;
virtual void callFunctionByName(std::string methodName, const rapidjson::Value* arguments, ActionParseDelegate* parseDelegate, std::function<void()> callback = [](){}) override;
virtual std::string getPropertyAsString(std::string propertyName = "") override;
protected:
bool _enabled;
bool _pressed;
bool _chosen;
bool _allowChoosing;
float _chosenScale;
float _pressedScale;
float _normalScale;
float _chosenRotation;
float _normalRotation;
int _chosenDepth;
int _pressedDepth;
int _normalDepth;
// TODO this should be a more generic piece of data
cocos2d::Color3B _colour;
float _brushSize;
cocos2d::Size _touchSize;
std::string _soundPath;
virtual void configureTouchListeners(bool swallowTouches);
virtual void notifyParentPalette();
};
#endif /* ToyPaletteComponentSprite_h */