zoukankan      html  css  js  c++  java
  • cocos进阶教程(5)回调函数和定时器的使用技巧

    cc.CallFunc.create(selector, data)

    selector:函数名(函数指针)

    data:参数 table类型

    函数写法

    function(node,args )

    node:动作调用对象,这个在系统会在-runAction的时候自动赋值进去的,不需要cc.CallFunc.create(selector, data)这里添加对象

    args:这里是table格式的 参数表

    function TestView:onCreate()
        local function func1(arg1, arg2)
            dump(arg1,"arg1")
            dump(arg2,"arg2")
        end
    
        local function func2(arg1, arg2)
            dump(arg1,"arg1")
            dump(arg2,"arg2")
        end
    
        local function func3(arg1, arg2)
            dump(arg1,"arg1")
            dump(arg2,"arg2")
        end
    
        local node = cc.Node:create()
        --这里必须要addChild(node),是生命周期跨越该函数 和 TestView同步 不然没法runAction 因为主对象没有
        self:addChild(node)
        dump(node,"node")
        local actions = {}
        local act1 = cc.CallFunc:create(func1, {"a","b","c"})
        local act2 = cc.CallFunc:create(func2, {"aa","bb","cc"})
        local act3 = cc.CallFunc:create(func3, {"aaa","bbb","ccc"})
        actions = {act2, act3, act1}
    
        local seq = cc.Sequence:create(actions)
        node:runAction(seq)
    end

     Layer

    layer:scheduleUpdateWithPriorityLua(update,0)

    CameraZoomTest_layer:scheduleUpdateWithPriorityLua(CameraZoomTest_update, 0)

    layer:unscheduleUpdate()

    layer:registerScriptHandler(onNodeEvent)

    Node

    StressTest2_entry = scheduler:scheduleScriptFunc(shouldNotLeak, 6.0, false)

    scheduler:unscheduleScriptEntry(StressTest2_entry)

  • 相关阅读:
    Rocketmq
    HTTPS 证书显示不安全
    js json 转为url参数
    Telnet 安装
    自己配置环境变量不起作用的问题
    Android笔记-Dalvik VM-1
    Fuzzy Logic/Expert System/Control
    PhD第一学期小结
    linux中的>、>>、2>&1、管道命令
    Hyper-v虚拟机设置静态IP
  • 原文地址:https://www.cnblogs.com/damowang/p/5009908.html
Copyright © 2011-2022 走看看