瀏覽代碼

Added listen(), unlisten(), and emit() to gbe.nodes.Node. These are wrappers around the gbe.events.Events object.

master
Bryan Miller 6 年之前
父節點
當前提交
b7ad19d490
共有 1 個檔案被更改,包括 17 行新增0 行删除
  1. +17
    -0
      game/gbe/nodes.py

+ 17
- 0
game/gbe/nodes.py 查看文件

@@ -187,6 +187,23 @@ class Node:
return c
return None

def listen(self, signal, callback_fn):
try:
Events.listen(signal, callback_fn)
except Exception as e:
raise e

def unlisten(self, signal, callback_fn):
Events.unlisten(signal, callback_fn)

def emit(self, signal, data={}):
# NOTE: I'm currently forcing the existance of this "NODE" key in the dictionary given. Not sure if I'll keep this.
data["NODE"] = {
"name":self.name
"n":self
}
Events.emit(signal, data)

def _init(self):
if hasattr(self, "on_init"):
self.on_init()

Loading…
取消
儲存