44 #ifndef __CU_WIRE_NODE_H__
45 #define __CU_WIRE_NODE_H__
48 #include <cugl/2d/CUTexturedNode.h>
49 #include <cugl/math/CUPoly2.h>
50 #include <cugl/math/polygon/CUPathOutliner.h>
53 #define WIRE_SEGMENTS 8
118 #pragma mark Constructors
214 #pragma mark Static Constructors
222 static std::shared_ptr<WireNode>
alloc() {
223 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
224 return (node->init() ? node :
nullptr);
240 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
241 return (node->init(vertices) ? node :
nullptr);
258 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
259 return (node->initWithVertices(vertices,traversal) ? node :
nullptr);
274 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
275 return (node->init(poly) ? node :
nullptr);
288 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
289 return (node->init(rect) ? node :
nullptr);
301 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
302 return (node->initWithLine(origin,dest) ? node :
nullptr);
317 unsigned int segments = WIRE_SEGMENTS) {
318 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
319 return (node->initWithEllipse(center,size,segments) ? node :
nullptr);
351 const std::shared_ptr<JsonValue> data) {
352 std::shared_ptr<WireNode> result = std::make_shared<WireNode>();
353 if (!result->initWithData(loader,data)) { result =
nullptr; }
354 return std::dynamic_pointer_cast<
Node>(result);
358 #pragma mark Attributes
390 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
444 void setEllipse(
const Vec2& center,
const Size& size,
unsigned int segments = WIRE_SEGMENTS);
447 #pragma mark Rendering
471 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
476 CU_DISALLOW_COPY_AND_ASSIGN(
WireNode);
Definition: CUWireNode.h:107
static std::shared_ptr< WireNode > allocWithRect(const Rect &rect)
Definition: CUWireNode.h:287
bool initWithEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
Definition: CUTexturedNode.h:84
void setLine(const Vec2 &origin, const Vec2 &dest)
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
static std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data)
Definition: CUWireNode.h:350
Definition: CUPoly2.h:115
bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data) override
std::string _classname
Definition: CUTexturedNode.h:88
static std::shared_ptr< WireNode > allocWithVertices(const std::vector< Vec2 > &vertices, PathTraversal traversal)
Definition: CUWireNode.h:256
~WireNode()
Definition: CUWireNode.h:139
PathTraversal getTraversal() const
Definition: CUWireNode.h:378
void setTraversal(PathTraversal traversal)
static PathOutliner _outliner
Definition: CUWireNode.h:111
void setEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
virtual void dispose() override
static std::shared_ptr< WireNode > allocWithEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
Definition: CUWireNode.h:316
PathTraversal _traversal
Definition: CUWireNode.h:114
Definition: CUSceneLoader.h:77
static std::shared_ptr< WireNode > allocWithLine(const Vec2 &origin, const Vec2 &dest)
Definition: CUWireNode.h:300
WireNode()
Definition: CUWireNode.h:127
static std::shared_ptr< WireNode > alloc()
Definition: CUWireNode.h:222
bool initWithLine(const Vec2 &origin, const Vec2 &dest)
std::string _name
Definition: CUNode.h:189
virtual void setPolygon(const std::vector< Vec2 > &vertices) override
Definition: CUColor4.h:1084
PathTraversal
Definition: CUPathOutliner.h:49
Definition: CUPathOutliner.h:78
static std::shared_ptr< WireNode > allocWithPoly(const Poly2 &poly)
Definition: CUWireNode.h:273
Definition: CUAction.h:51
static std::shared_ptr< WireNode > allocWithVertices(const std::vector< Vec2 > &vertices)
Definition: CUWireNode.h:239
bool initWithVertices(const std::vector< Vec2 > &vertices, PathTraversal traversal)