#pragma once #include #include #include namespace easy2d { class ScriptNode : public Node { public: ScriptNode(); ~ScriptNode() override; static Ptr create(const std::string& scriptPath); bool loadScript(const std::string& scriptPath); const std::string& getScriptPath() const { return scriptPath_; } void onEnter() override; void onExit() override; void onUpdate(float dt) override; private: bool callMethod(const char* name); bool callMethodWithFloat(const char* name, float arg); void pushSelf(); std::string scriptPath_; HSQOBJECT scriptTable_; bool tableValid_ = false; }; } // namespace easy2d