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)

  • 相关阅读:
    跨浏览器OCX
    安装QT5.02
    Ubuntu登陆密码忘记
    QTableView
    VMware安装时Error 1324. The path My Documents contains a invalid character的原因和解决方法
    VS2005 与虚拟机的那点事
    创建掩码位图来实现透明绘图
    【转载】spring注解整理
    记录spring test类无法插入数据问题
    Uniapp 原生开发uniapp.arr 新老兼容问题
  • 原文地址:https://www.cnblogs.com/damowang/p/5009908.html
Copyright © 2011-2022 走看看