当前位置: 首页>>代码示例>>Python>>正文


Python Scene.on_exit方法代码示例

本文整理汇总了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'
开发者ID:Anaphory,项目名称:cocos,代码行数:34,代码来源:test_director_scene_changes.py

示例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
开发者ID:Anaphory,项目名称:cocos,代码行数:43,代码来源:test_director_scene_changes.py


注:本文中的cocos.scene.Scene.on_exit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。