On Fri, Oct 26, 2012 at 5:38 PM, Jason <[email protected]> wrote:
> What's the best way to just pause the game. Let's say the user has caused
> the game to be over through some lose condition. I jsut want to pause all
> the actions in the scene and layers, then throw up some info on a Sprite or
> Label or whatehaveyou.
>
>
This is from the active layer and is called by a lose condition in one of
> the game loops:
>
> def endGame(self):
> print 'GAME OVER MAN, GAME OVER!'
> nextScene = cocos.scenes.pause.get_pause_scene()
> nextScene.add(cocos.scenes.pause.PauseLayer())
> director.push(nextScene)
>
>
> BTW, this is the start.py script I have:
>
> def init():
> try:
> director.init()
> win = director.window
> cursor = win.get_system_mouse_cursor(BaseWindow.CURSOR_CROSSHAIR)
> win.set_mouse_cursor(cursor)
> StartScene = cocos.scene.Scene()
> StartScene.add(SpaceLayer())
>
> # StartScene.add(PlanetLayer(GlobalVariables()))
> # StartScene.add(CityLayer(GlobalVariables()))
> # StartScene.add(BuildingLayer(GlobalVariables()))
> director.run(StartScene)
> except:
> traceback.print_exc(file=sys.stdout)
> pyglet.app.exit()
> sys.exit()
>
> The commented out bits are just to test the different layers. Each one is
> put into a Scene object, then has the director push it out from the
> previous layer. Both handleLaunchCraft and endGame are called from the
> active layer.
>
> def handleLaunchCraft(self):
> if (self.currentPopnCenter != ''):
> nextScene = cocos.scene.Scene()
> nextScene.add(self.getNextLayer())
> director.push(nextScene)
>
>
>
>
But then I get a PAUSE text up front, is there any way to override that?
>
>
In your endGame method you are:
using the default pause scene, which adds that text
adding the PauseLayer, which also display that text
So
don't add cocos.scene.pause.PauseLayer,
dont get the pause scene with cocos.scenes.pause.get_pause_scene();
instead copy paste the function cocos.pause.default_pause_scene , rename
it, and shorten the return line to
return PauseScene(texture.get_region(0, 0, w, h))
Obviously you can add the other info you want to display.
> Also, am I structuring this correctly?
>
>
When the old scene is never to continue, it is better to use
director.replace than director.push: some resources are then released.
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en.