Mushroom Node
Mushroom Migration
As an in-world entity, the Mushroom must become a Node to inherit its Update and Draw methods. Instead of directly manipulating the sprite's position, the mushroom's transform will now handle world translation, and the sprite will be drawn at the mushroom's transform. Since the mushroom resides at the scene tree's root, its local transform directly mirrors its global transform.
// -----
#include "engine/node.h" // Add: Include.
namespace game {
class Mushroom : public ng::Node { // Add: Inherit from Node.
public:
Mushroom(ng::App* app, const ng::Tilemap* tilemap);
// --- 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