Background Node
Background Migration
As an in-world entity, the Background must become a Node to inherit its Update and Draw methods. The background's transform will now handle world translation, and the texture will be drawn at the background's transform.
// -----
#include "engine/node.h" // Add: Include.
namespace game {
class Background : public ng::Node { // Add: Inherit from Node.
public:
Background(ng::App* app, sf::Vector2u size);
// --- Change: Instead of having a public Update and Draw, override the node's methods. ---
protected:
void Update() override;
void Draw(sf::RenderTarget& target) override;
// --- End ---
// -----
private:
ng::App* app_ = nullptr; // Remove.
};
} } // namespace gameLast updated