Pārlūkot izejas kodu

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

master
Bryan Miller pirms 6 gadiem
vecāks
revīzija
a2f6aaaa7e
1 mainītis faili ar 14 papildinājumiem un 3 dzēšanām
  1. +14
    -3
      game/gbe/nodes.py

+ 14
- 3
game/gbe/nodes.py Parādīt failu

@@ -247,7 +247,10 @@ class Node2D(Node):
try:
Node.__init__(self, name, parent)
except NodeError as e:
raise e
raise e
self._NODE2D_DATA = {
"visible":True
}

@property
def resolution(self):
@@ -259,6 +262,13 @@ class Node2D(Node):
# Otherwise the Display object should.
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):
if hasattr(self, "on_render"):
self._ACTIVE_SURF = surface
@@ -266,8 +276,9 @@ class Node2D(Node):
del self._ACTIVE_SURF

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):
if not hasattr(self, "_ACTIVE_SURF"):

Notiek ielāde…
Atcelt
Saglabāt