47 #ifndef __CU_BUTTON_H__
48 #define __CU_BUTTON_H__
49 #include <cugl/assets/CUJsonValue.h>
50 #include <cugl/2d/CUNode.h>
51 #include <cugl/2d/CUPolygonNode.h>
52 #include <cugl/math/CUColor4.h>
53 #include <unordered_map>
58 #pragma mark ButtonListener
78 typedef std::function<void(const std::string& name, bool down)>
ButtonListener;
132 #pragma mark Constructors
158 virtual void dispose()
override;
169 CUAssertLog(
false,
"This node does not support the empty initializer");
183 bool init(
const std::shared_ptr<Node>& up) {
198 bool init(
const std::shared_ptr<Node>& up,
Color4 down);
212 bool init(
const std::shared_ptr<Node>& up,
const std::shared_ptr<Node>& down);
241 #pragma mark Static Constructors
252 static std::shared_ptr<Button>
alloc(
const std::shared_ptr<Node>& up) {
253 std::shared_ptr<Button> node = std::make_shared<Button>();
254 return (node->init(up) ? node :
nullptr);
268 static std::shared_ptr<Button>
alloc(
const std::shared_ptr<Node>& up,
Color4 down) {
269 std::shared_ptr<Button> node = std::make_shared<Button>();
270 return (node->init(up,down) ? node :
nullptr);
285 static std::shared_ptr<Button>
alloc(
const std::shared_ptr<Node>& up,
const std::shared_ptr<Node>& down) {
286 std::shared_ptr<Button> node = std::make_shared<Button>();
287 return (node->init(up,down) ? node :
nullptr);
316 const std::shared_ptr<JsonValue> data) {
317 std::shared_ptr<Button> result = std::make_shared<Button>();
318 if (!result->initWithData(loader,data)) { result =
nullptr; }
319 return std::dynamic_pointer_cast<
Node>(result);
322 #pragma mark Button Attributes
368 void setPushable(
const std::vector<Vec2>& vertices);
379 #pragma mark Button State
436 #pragma mark Listeners
470 void setListener(ButtonListener listener) { _listener = listener; }
Definition: CUPoly2.h:115
std::function< void(const std::string &name, bool down)> ButtonListener
Definition: CUButton.h:78
static const Color4 GRAY
Definition: CUColor4.h:1124
Definition: CUSceneLoader.h:77
Definition: CUColor4.h:1084
Definition: CUAction.h:51