def load_scene(name): """ Load data from cache/disk, parse it and create a new scene deactivated empty scene and reference it . Then parse all the gameobjects using GameObjectLoader (see the gameobjects docs), add them. Finally activate the scene and spawn the GameObjects. The name of the scene is the filename of the scene data file without the extension. """ destroy_current() gvars.current_scene = Scene(name) gos = _load_gameobjects(load_raw_data(name)) _spawn_gameobjects(gos) gvars.current_scene.activate()
def initGame(self, mainFile, externalComponents=None, buttonCallbacks=None): self._buttonCallbacks = buttonCallbacks self._externalComponents = externalComponents data = engine.file.getJsonData(mainFile) if "game" in data: if "title" in data["game"]: pygame.display.set_caption(data["game"]["title"]) if "icon" in data["game"]: img = self.getRenderer().getImage(data["game"]["icon"]) pygame.display.set_icon(img) if "mainScene" in data: scene = Scene(data["mainScene"]) self.setActiveScene(scene)
def __init__(self): Scene.__init__(self)
def exit(self, screen): Scene.exit(self, screen)
def loop(self, screen): Scene.loop(self, screen)
def init(self): Scene.init(self)
def add_scene(self, scn: Scene) -> Scene: scn.setup() self.scenes.append(scn) if self.iscene == -1: self.iscene = len(self.scenes) - 1 return scn
def new_scene(self) -> Scene: scn = Scene() return self.add_scene(scn)