Hi ! I'm actually coding a little game and I have some problem with scenegraph implementation.
Here's my base Node class:
class Node: public sf::Drawable, public sf::Transformable
{
public:
Node(const sf::Vector2f & origin, const sf::Vector2f & pos,
const std::string & id, bool drawnAbove = true);
virtual void Step(sf::Time frametime);
//Add a new child to the node.
bool BindNode(std::unique_ptr<Node> & node);
//Remove a child and get it.
std::unique_ptr<Node> UnbindNode(const std::string & id);
//Get a child with it ID.
Node * GetChild(const std::string & id);
unsigned int GetChildCount() const;
const std::string & GetId() const;
void SetDrawnAboveParent(bool drawnAbove);
bool IsDrawnAboveParent() const;
virtual void OnDraw(sf::RenderTarget & target, const sf::Transform & trans) const;
protected:
virtual void draw(sf::RenderTarget &target, sf::RenderStates States) const;
//Childs.
std::map<std::string, std::unique_ptr<Node> > m_childs;
std::string m_id;
bool m_drawnAboveParent;
};
I also implemented a spriteNode and an animationNode which have Node as base class. My question is:
If I use those classes to create an animated character (for example): Every part of the character would be a spriteNode which has as parent an animationNode (walk animation, attack animation, etc...). How can I access the animation node and modify them effectively to the animation I want ?
Thanks for your answer !