diff --git a/Godot GDScript Trick.md b/Godot GDScript Trick.md index 2969c9a..9506845 100644 --- a/Godot GDScript Trick.md +++ b/Godot GDScript Trick.md @@ -57,27 +57,27 @@ static func example(): func _has(key:String)->bool: return _all_events.has(key) -func _get(key) -> Variant: +func _get_actions(key:String) -> Variant: return _all_events[key] - + func add(key:String,action:Callable): if !_has(key): var empty : Array[Callable] = [] _all_events[key] = empty - _all_events[key].append(action) + _get_actions(key).append(action) func erase(key:String, action:Callable): if _has(key): - _get(key).erase(action) + _get_actions(key).erase(action) func trigger(event_key:String): if _has(event_key): - for event in _all_events[event_key]: + for event in _get_actions(event_key): event.call() func trigger_data(event_key:String, data): if _has(event_key): - for event in _all_events[event_key]: + for event in _get_actions(event_key): event.call(data) ``` 推荐使用样例 diff --git a/TODO.md b/TODO.md index ea431dc..30c9de5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ ## 2013-10-14 -- 做好 Signal up 的解决方案文档 +- [x] 做好 Signal up 的解决方案文档 - 把游戏的UI流程进行一个梳理与绘图 - 在引擎中实现这个流程, 并用Signal进行关联, 不含非UI的逻辑代码 - 修改与验收阶段