From: Stefano Rivera Date: Sun, 11 May 2014 16:03:18 +0000 (+0200) Subject: Scenes have a widget list (in draw order) X-Git-Tag: 0.1~416 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=24597ee01bda34802e020147c48fba7d131f0698;p=naja.git Scenes have a widget list (in draw order) --- diff --git a/naja/scenes/menu.py b/naja/scenes/menu.py index 7b42ad7..c1fd5f8 100644 --- a/naja/scenes/menu.py +++ b/naja/scenes/menu.py @@ -9,10 +9,9 @@ from naja.widgets.text import TextWidget class MenuScene(Scene): def __init__(self): - self.tw = TextWidget((10, 10), 'Haai', colour=(255, 255, 255)) - - def render(self, surface): - self.tw.render(surface) + super(MenuScene, self).__init__() + self.widgets.append(TextWidget((10, 10), 'Haai', + colour=(255, 255, 255))) def handle_event(self, ev): pass diff --git a/naja/scenes/scene.py b/naja/scenes/scene.py index c82427d..f0acf21 100644 --- a/naja/scenes/scene.py +++ b/naja/scenes/scene.py @@ -10,7 +10,7 @@ class Scene(object): E.g. Splash screen, game board, credits, win, lose. """ def __init__(self): - pass + self.widgets = [] def enter(self): pass @@ -19,7 +19,11 @@ class Scene(object): pass def render(self, surface): - pass + self.render_widgets(surface) + + def render_widgets(self, surface): + for widget in self.widgets: + widget.render(surface) def handle_event(self, ev): pass