From 24597ee01bda34802e020147c48fba7d131f0698 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 11 May 2014 18:03:18 +0200 Subject: [PATCH] Scenes have a widget list (in draw order) --- naja/scenes/menu.py | 7 +++---- naja/scenes/scene.py | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) 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 -- 2.34.1