瀏覽代碼

Can now set a Node2D-based instance as visible. If false, rendering of the sub-tree from that node will stop.

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

+ 14
- 3
game/gbe/nodes.py 查看文件

try: try:
Node.__init__(self, name, parent) Node.__init__(self, name, parent)
except NodeError as e: except NodeError as e:
raise e
raise e
self._NODE2D_DATA = {
"visible":True
}


@property @property
def resolution(self): def resolution(self):
# Otherwise the Display object should. # Otherwise the Display object should.
return Display.resolution return Display.resolution


@property
def visible(self):
return self._NODE2D_DATA["visible"]
@visible.setter
def visible(self, vis):
self._NODE2D_DATA["visible"] = (vis == True)

def _callOnRender(self, surface): def _callOnRender(self, surface):
if hasattr(self, "on_render"): if hasattr(self, "on_render"):
self._ACTIVE_SURF = surface self._ACTIVE_SURF = surface
del self._ACTIVE_SURF del self._ACTIVE_SURF


def _render(self, surface): def _render(self, surface):
self._callOnRender(surface)
Node._render(self, surface)
if self._NODE2D_DATA["visible"]:
self._callOnRender(surface)
Node._render(self, surface)


def draw_image(self, img, pos=(0,0), rect=None): def draw_image(self, img, pos=(0,0), rect=None):
if not hasattr(self, "_ACTIVE_SURF"): if not hasattr(self, "_ACTIVE_SURF"):

Loading…
取消
儲存