main
Yogi 2023-10-15 14:37:59 +08:00
parent a9077781fe
commit dc4c2714eb
2 changed files with 7 additions and 7 deletions

View File

@ -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)
```
推荐使用样例

View File

@ -1,6 +1,6 @@
## 2013-10-14
- 做好 Signal up 的解决方案文档
- [x] 做好 Signal up 的解决方案文档
- 把游戏的UI流程进行一个梳理与绘图
- 在引擎中实现这个流程, 并用Signal进行关联 不含非UI的逻辑代码
- 修改与验收阶段