Esc popping out a scene

11 views
Skip to first unread message

Jason

unread,
Oct 19, 2012, 4:11:36 PM10/19/12
to cocos-...@googlegroups.com
I'm working a game that pushes scenes onto the stack. So you are going from one level to the next. At a certain point, the game will bring the player back through these levels.

However, when you press ESC, it pops the current scene out of the stack, and starts running the previous one. Is there any way for me to stop that?

Cheers,
J

claudio canepa

unread,
Oct 19, 2012, 4:48:06 PM10/19/12
to cocos-...@googlegroups.com

--
 

Yes.
Most surely you have an on_key_press handler in your scene (be it directly in the scene or in a layer added to the scene)
what you want is add in that handler

if symbol == key.ESCAPE:
      return True

The return True tells the event dispatcher that the event has been handled and to please do not pass to other handlers. Perfect, the ESC will not reach the code in cocos.director.DefaultHandler, the responsible to call director pop when it sees an ESC.


Reply all
Reply to author
Forward
0 new messages