本文整理汇总了Python中cocos.scene.Scene.on_exit方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.on_exit方法的具体用法?Python Scene.on_exit怎么用?Python Scene.on_exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos.scene.Scene
的用法示例。
在下文中一共展示了Scene.on_exit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_6_on_pop_calls_on_enter_on_exit
# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import on_exit [as 别名]
def test_6_on_pop_calls_on_enter_on_exit(self):
global rec
scene0 = Scene()
scene1 = Scene()
def on_exit():
global rec
rec.append('on_exit_called')
def on_enter():
global rec
rec.append('on_enter_called')
scene0.on_enter = on_enter
scene1.on_exit = on_exit
rec = []
director.on_push(scene0)
# pyglet mockup 1 don't tickle on_draw, we call
# directly so the push / pop operation completes
director.on_draw()
director.on_push(scene1)
director.on_draw()
rec = []
director.on_pop()
director.on_draw()
assert rec[0]=='on_exit_called'
assert rec[1]=='on_enter_called'
示例2: test_7_replace
# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import on_exit [as 别名]
def test_7_replace(self):
global rec
scene0 = Scene()
scene1 = Scene()
scene2 = Scene()
def on_exit():
global rec
rec.append('on_exit_called')
def on_enter():
global rec
rec.append('on_enter_called')
scene1.on_exit = on_exit
scene2.on_enter = on_enter
director.on_push(scene0)
# pyglet mockup 1 don't tickle on_draw, we call
# directly so the push / pop operation completes
director.on_draw()
director.on_push(scene1)
director.on_draw()
rec = []
director.replace(scene2)
director.on_draw()
# final scene ok
assert director.scene is scene2
# old scene on_exit called, new scene on_enter called
assert rec[0]=='on_exit_called'
assert rec[1]=='on_enter_called'
# underlaying scene ok
director.on_pop()
director.on_draw()
assert director.scene is scene0