| 790 | } |
| 791 | |
| 792 | void Node::onUpdate(const Update& func) { |
| 793 | auto updateItem = getUpdateItem(); |
| 794 | auto funcRef = std::make_shared<Update>(); |
| 795 | std::weak_ptr<Update> weak(funcRef); |
| 796 | *funcRef = [func, weak](double deltaTime) { |
| 797 | std::shared_ptr<Update> ref(weak); |
| 798 | return func(deltaTime); |
| 799 | }; |
| 800 | updateItem->scheduledThreadFuncs.push_back(funcRef); |
| 801 | if (_flags.isOff(Node::Running)) return; |
| 802 | if (!updateItem->scheduled()) { |
| 803 | _scheduler->schedule(updateItem->scheduledItem.get()); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | void Node::clearUpdate() { |
| 808 | if (!_updateItem) return; |