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


Python cocosnode.CocosNode类代码示例

本文整理汇总了Python中cocos.cocosnode.CocosNode的典型用法代码示例。如果您正苦于以下问题:Python CocosNode类的具体用法?Python CocosNode怎么用?Python CocosNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CocosNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_crossing_total_duration_at_1st_step

    def test_update_crossing_total_duration_at_1st_step(self, duration1, duration2):
        # elapsed==0, next_elapsed>=duration1 + duration2
        global rec
        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UIntervalAction(name1, duration1)
        a2 = UIntervalAction(name2, duration2)
        elapsed = 0.0
        rec = []
        composite = ac.sequence(a1, a2)
        node.do(composite)
        next_elapsed = duration1 + duration2 +fe
        dt = next_elapsed - elapsed
        node._step(dt)
        # expected: for both actions start-update(1)-stop called, in that order
        recx = [ e for e in rec if e[1]!='step' ]
        rec = [ e for e in recx if e[0]==name1]
        print 'rec',rec
        assert len(rec)==3
        assert rec[0][1]=='start'
        assert rec[1][1]=='update' and rec[1][2]==1.0
        assert rec[2][1]=='stop'

        rec = [ e for e in recx if e[0]==name2]
        print 'rec',rec
        assert len(rec)==3
        assert rec[0][1]=='start'
        assert rec[1][1]=='update' and rec[1][2]==1.0
        assert rec[2][1]=='stop'
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:30,代码来源:test_p_ba_Sequence_IntervalAction.py

示例2: test_update_crossing_max_at_1st_step

    def test_update_crossing_max_at_1st_step(self, duration1, duration2):
        # next_elapsed > max(duration1, duration2)
        global rec

        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UIntervalAction(name1, duration1)
        a2 = UIntervalAction(name2, duration2)
        composite = ac.spawn(a1, a2)
        rec = []
        node.do(composite)
        elapsed = 0.0
        next_elapsed = max(duration1, duration2)*1.1 # above max
        dt = next_elapsed - elapsed
        node._step(dt)

        recx = [ e for e in rec if e[1]!='step' ]
        rec = [ e for e in recx if e[0]==name1]
        print 'rec',rec
        assert rec[0][1]=='start'
        assert rec[1][1]=='update' and rec[1][2]==1.0
        assert rec[2][1]=='stop'
        assert len(rec)==3

        rec = [ e for e in recx if e[0]==name2]
        print 'rec:', rec
        assert rec[0][1]=='start'
        assert rec[1][1]=='update' and rec[1][2]==1.0
        assert rec[2][1]=='stop'
        assert len(rec)==3
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:31,代码来源:test_p_ba_Spawn_IntervalAction.py

示例3: test_update_crossing_duration1_not_duration_at_1st_step

    def test_update_crossing_duration1_not_duration_at_1st_step(self, duration1, duration2):
        global rec

        if duration2==0.0:
            return

        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UIntervalAction(name1, duration1)
        a2 = UIntervalAction(name2, duration2)
        composite = ac.sequence(a1, a2)
        rec = []
        node.do(composite)
        elapsed = 0.0
        next_elapsed = (duration1 + duration2)/2.0
        dt = next_elapsed - elapsed
        node._step(dt)

        #expect start, update(1), stop for action 1, start + update(x) for action2
        recx = [ e for e in rec if e[1]!='step' ]
        rec = [ e for e in recx if e[0]==name1]
        print 'rec',rec
        assert rec[0][1]=='start'
        assert rec[1][1]=='update' and rec[1][2]==1.0
        assert rec[2][1]=='stop'
        assert len(rec)==3

        rec = [ e for e in recx if e[0]==name2]
        print 'rec',rec
        assert rec[0][1]=='start'
        assert rec[1][1]=='update'
        assert abs(rec[1][2]-(next_elapsed-duration1)/duration2)<fe
        assert len(rec)==2
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:34,代码来源:test_p_ba_Sequence_IntervalAction.py

示例4: test_node_stop_calls_remove_and_not_anything_in_action

 def test_node_stop_calls_remove_and_not_anything_in_action(self):
     global rec, next_done
     next_done = 0
     node = CocosNode()
     name1 = '1'
     action1 = UAction(name1)
     name2 = '2'
     action2 = UAction(name2)
     a1_copy = node.do(action1)
     a2_copy = node.do(action2)
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:10,代码来源:test_p_ba_cocosnode_actions.py

示例5: test_target_set

    def test_target_set(self):
        global rec, next_done
        node = CocosNode()
        name1 = '1'
        a1 = UAction(name1)
        composite = ac.Repeat(a1)

        rec = []
        a_copy = node.do(composite)
        assert a_copy.action.target==node
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:10,代码来源:test_p_ba_Repeat_Action.py

示例6: test_Loop_InstantAction

def test_Loop_InstantAction():
    rec = []
    def f(x):
       rec.append(x)
    node = CocosNode()
    template_action = cocos.actions.instant_actions.CallFunc(f, 1)
    n = 5
    action = template_action * n
    node.do(action)
    assert rec == [1] * n
开发者ID:1414648814,项目名称:cocos,代码行数:10,代码来源:test_instant_actions.py

示例7: test_target_set

    def test_target_set(self):
        global rec, next_done
        next_done=0
        node = CocosNode()
        name1 = '1'
        times = 2
        a1 = UAction(name1)
        composite = ac.loop(a1, times)

        rec = []
        a_copy = node.do(composite)
        assert a_copy.current_action.target==node
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:12,代码来源:test_p_ba_Loop_Actions.py

示例8: test_target_set

    def test_target_set(self):
        global rec
        node = CocosNode()
        name1 = '1'
        duration1 = 3.0
        times = 2
        a1 = UIntervalAction(name1, duration1)
        composite = ac.loop(a1, times)

        rec = []
        a_copy = node.do(composite)
        assert a_copy.current_action.target==node
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:12,代码来源:test_p_ba_Loop_IntervalAction.py

示例9: test_target_set_next_time

    def test_target_set_next_time(self):
        global rec, next_done
        node = CocosNode()
        name1 = '1'
        a1 = UAction(name1)
        composite = ac.Repeat(a1)

        a_copy = node.do(composite)
        dt = 0.1
        next_done=1
        node._step(dt)
        assert a_copy.action.target==node
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:12,代码来源:test_p_ba_Repeat_Action.py

示例10: test_life_cycle

    def test_life_cycle(self):
        global rec, next_done
        next_done=0
        name1 = '1'
        times = 2
        a1 = UAction(name1)
        node = CocosNode()
        composite = ac.loop(a1, times)
        
        #1st start
        rec = []
        a_copy = node.do(composite)
        assert rec[0]==(name1, 'start')
        assert len(rec)==1
        assert not a_copy.done()

        #step in first repetition
        dt = 0.1
        next_done=0
        rec = []
        node._step(dt)
        assert rec[0]==(name1, 'step', dt) 
        assert len(rec)==1
        assert not a_copy.done()

        #termination first repetion, start second repetition
        next_done = 1
        rec = []
        node._step(dt)
        assert rec[0]==(name1, 'step', dt) 
        assert rec[1]==(name1, 'stop')
        assert rec[2]==(name1, 'start')
        assert len(rec)==3
        assert not a_copy.done()

        #step in second repetition
        next_done=0
        rec = []
        node._step(dt)
        assert rec[0]==(name1, 'step', dt) 
        assert len(rec)==1
        assert not a_copy.done()

        #terminatation last repetition
        next_done = 1
        rec = []
        node._step(dt)
        assert rec[0]==(name1, 'step', dt) 
        assert rec[1]==(name1, 'stop')
        assert len(rec)==2

        assert a_copy.done()
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:52,代码来源:test_p_ba_Loop_Actions.py

示例11: test_target_set

    def test_target_set(self, duration1, duration2):
        global rec
        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UIntervalAction(name1, duration1)
        a2 = UIntervalAction(name2, duration2)
        composite = ac.spawn(a1, a2)

        rec = []
        a_copy = node.do(composite)
        assert a_copy.actions[0].target==node
        assert a_copy.actions[1].target==node
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:13,代码来源:test_p_ba_Spawn_IntervalAction.py

示例12: test_start

    def test_start(self, duration1, duration2):
        global rec
        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UIntervalAction(name1, duration1)
        a2 = UIntervalAction(name2, duration2)
        composite = ac.spawn(a1, a2)

        rec = []
        node.do(composite)
        assert [e for e in rec if e[0]==name1][0]==(name1, 'start') 
        assert [e for e in rec if e[0]==name2][0]==(name2, 'start')
开发者ID:eevee,项目名称:cocos2d-mirror,代码行数:13,代码来源:test_p_ba_Spawn_IntervalAction.py

示例13: _selected_fn

        def _selected_fn(spr: cocosnode.CocosNode):
            self.orig_scale = spr.scale
            self.orig_pos = spr.position

            spr.scale *= 2
            y_ratio = spr.y / get_height()
            if y_ratio < 0.5:
                spr.y = min(y_ratio + 0.13, 0.5) * get_height()
            else:
                spr.y = max(y_ratio - 0.13, 0.5) * get_height()

            if self.move_to_top:
                set_z(spr, z='top')
开发者ID:fyabc,项目名称:MiniGames,代码行数:13,代码来源:select_effect.py

示例14: test_do_inmediate_effects1

 def test_do_inmediate_effects1(self):
     # do called without an explicit target
     global rec, next_done
     next_done = 0
     node = CocosNode()
     name1 = '1'
     action = UAction(name1)
     rec = []
     a_copy = node.do(action)
     assert a_copy.target == node
     assert a_copy in node.actions
     assert len(node.actions)==1
     assert rec[0]==(name1, 'start')
     assert len(rec)==1
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:14,代码来源:test_p_ba_cocosnode_actions.py

示例15: test_target_set

    def test_target_set(self):
        global rec, next_done
        next_done=0
        node = CocosNode()
        name1 = '1'
        name2 = '2'
        a1 = UAction(name1)
        a2 = UAction(name2)
        composite = ac.sequence(a1, a2)

        rec = []
        a_copy = node.do(composite)
        assert a_copy.one.target==node
        assert a_copy.two.target==node
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:14,代码来源:test_p_ba_Sequence_Action.py


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