Class CanvasNode

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class CanvasNode : public simple2dengine::Node

Canvas node. Used for drawing, transforming, positioning.

Subclassed by simple2dengine::SpriteNode, simple2dengine::TextNode

Public Functions

bool addChild(std::shared_ptr<CanvasNode> child)

Add child to canvas node tree.

Return
true if successfully add a node, otherwise return false.
Parameters
  • child: will be added to node tree.

void setPosition(const sf::Vector2f &position)

Set position of Node.

Parameters
  • position: x and y coordinates relative to its parent.

void move(const sf::Vector2f &position)

Move Node on specified coordinates.

Parameters
  • position: x and y coordinate relative to its parent.

const sf::Vector2f &getPosition() const

Get position of Node relative to parent.

Return
const Vector2f& x and y coordinate relative to parent.

const sf::Vector2f &getGlobalPosition() const

Get global position of Node.

Return
const Vector2f& x and y coordinate relative to window (global position).

void setVisible(bool isVisible)

Set visibility of Node. If parent is invisible, curent Node will be invisible too.

Parameters
  • isVisible: visibility of Node.

bool isVisible() const

Check if Node is visible or not.

Return
bool visibility of Node.

bool isVisibleInTree() const

Check if Node or it parents are visible or not. If someone of Node or its parents is invisible - return value will be false.

Return
bool visibility of Node or it parents.

void setAnchor(const Anchor anchor)

Set Node anchor.

Parameters
  • anchor: anchor.

Anchor getAnchor() const

Get anchor of Node.

Return
Anchor.

virtual void updateTransform()

Update Canvas node transform to correctly draw it.