博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocos2dx lua CCCallFunc 传递参数
阅读量:4215 次
发布时间:2019-05-26

本文共 1062 字,大约阅读时间需要 3 分钟。

1、不需要参数:

function actionEndFunc()

        LuaLog("++++++++++++++++++++++++++11111111")
end
dialogBg:setScale(1/100)
local actionScale = CCScaleTo:create(0.3, 1)
local callfunc = CCCallFunc:create(actionEndFunc)
local actionSequence = CCSequence:createWithTwoActions(actionScale, callfunc)
dialogBg:runAction(actionSequence)

2、传递参数:--摘自网路。

-- wrapper for callback with arguments

function callbackWithArgs(callback, args)
    local params = args
    local ret = function ()
    -- body
        callback(args)
    end
    return ret
end
-- performWithDelay version 2
function performWithDelay(node, callback, delay, args)
    local delay = CCDelayTime:create(delay)
    local callfunc = CCCallFunc:create(callbackWithArgs(callback, args)
    local sequence = CCSequence:createWithTwoActions(delay, callfunc)
    node:runAction(sequence)
    return sequence
end
-- your callback will be simple
function changeScene(args)
    -- body
    local aboutGame = args.screen.create()
    CCDirector:sharedDirector():replaceScene(aboutGame)
end
-- Finally, here is a usage.
performWithDelay(sceneGame, changeScene, 1, {screen=aboutscreen})

参考:

转载地址:http://bvsmi.baihongyu.com/

你可能感兴趣的文章
RobotFramework+Eclipse安装步骤
查看>>
测试的分类
查看>>
photoshop cc2019快捷键
查看>>
pycharm2019版本去掉下划线的方法
查看>>
九度OJ 1091:棋盘游戏 (DP、BFS、DFS、剪枝)
查看>>
leetcode 13: Roman to Integer
查看>>
a标签中调用js方法
查看>>
js函数中传入的event参数
查看>>
[hive]优化策略
查看>>
c++14现代内存管理
查看>>
右值引用,move语义和完美转发
查看>>
c++使用宏检测类是否包含某个函数或者变量属性
查看>>
CSS之Multi-columns的column-gap和column-rule
查看>>
CSS之Multi-columns的跨列
查看>>
CSS之浮动(一)
查看>>
CSS之浮动(二)
查看>>
AtomicInteger源码解析
查看>>
CopyOnWriteArraySet源码学习
查看>>
Openfiler 配置 NFS 示例
查看>>
Oracle 11.2.0.1 RAC GRID 无法启动 : Oracle High Availability Services startup failed
查看>>