newlist

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
上一页 1 2 3 4 5 6 7 8 9 ··· 26 下一页

2014年4月6日

摘要: clone深度克隆一个值。格式:value = clone(值)用法示例:-- 下面的代码,t2 是 t1 的引用,修改 t2 的属性时,t1 的内容也会发生变化local t1 = {a = 1, b = 2}local t2 = t1t2.b = 3 -- t1 = {a = 1, b = 3} <-- t1.b 发生变化 -- clone() 返回 t1 的副本,修改 t2 不会影响 t1local t1 = {a = 1, b = 2}local t2 = clone(t1)t2.b = 3 -- t1 = {a = 1, b = 2} <-- t1.b 不受影响 阅读全文
posted @ 2014-04-06 20:35 一枚程序 阅读(3400) 评论(0) 推荐(0) 编辑

2014年4月5日

摘要: --local MainSceneConfig = require "res.scripts.configs.MainSceneConfig" -- 暂时添加一个临时配置文件--require "res.scripts.scenes.MainScene"-- 加载事件OnLoadingStart = "OnLoadingStart";OnLoadingProcess = "OnLoadingProcess";OnLoadingEnd = "OnLoadingEnd";-- 加载类型SOUNDTY 阅读全文
posted @ 2014-04-05 22:36 一枚程序 阅读(1344) 评论(1) 推荐(0) 编辑

2014年3月18日

摘要: CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync("armature/robot.png", "armature/robot.plist", "armature/robot.xml", this, NULL);CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync("armature/hero.ExportJson 阅读全文
posted @ 2014-03-18 16:07 一枚程序 阅读(1643) 评论(0) 推荐(0) 编辑

2014年3月17日

摘要: CCSprite* pImgBg = CCSprite::create("1.png"); pImgBg->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2)); this->addChild(pImgBg); CCActionInterval *action = CCShatteredTiles3D::create(0.2f, CCSizeMake(16 阅读全文
posted @ 2014-03-17 11:18 一枚程序 阅读(334) 评论(0) 推荐(0) 编辑

2014年3月12日

摘要: local tonumber_ = tonumberfunction tonumber(v, base) return tonumber_(v, base) or 0endfunction toint(v) return math.round(tonumber(v))endfunction tobool(v) return (v ~= nil and v ~= false)endfunction totable(v) if type(v) ~= "table" then v = {} end return vendfunction clone(object) ... 阅读全文
posted @ 2014-03-12 10:32 一枚程序 阅读(9190) 评论(0) 推荐(1) 编辑

摘要: ---- Author: My Name-- Date: 2013-12-16 18:52:11-- csv解析 -- -- 去掉字符串左空白 local function trim_left(s) return string.gsub(s, "^%s+", ""); end -- 去掉字符串右空白 local function trim_right(s) return string.gsub(s, "%s+$", ""); end -- 解析一行 local function parseline(line) lo 阅读全文
posted @ 2014-03-12 10:23 一枚程序 阅读(2248) 评论(0) 推荐(1) 编辑

2014年3月9日

摘要: 只要是新的聊天对象就创建一个新的listview local name = tolua.cast(UIHelper:seekWidgetByName(self.nameItem, "name"), "Label"); local playerName = name:getStringValue(); if nil == self.privateChatList[name:getTag()] then local ChatListView = ListView:create(); if ChatListView == nil then ... 阅读全文
posted @ 2014-03-09 11:17 一枚程序 阅读(4299) 评论(0) 推荐(0) 编辑

2014年3月1日

摘要: Lua的函数参数是和位置相关的,调用时实参会按顺序依次传给形参。有时候用名字指定参数是很有用的,比如rename函数用来给一个文件重命名,有时候我们我们记不清命名前后两个参数的顺序了:-- invalid coderename(old="temp.lua", new="temp1.lua")上面这段代码是无效的,Lua可以通过将所有的参数放在一个表中,把表作为函数的唯一参数来实现上面这段伪代码的功能。因为Lua语法支持函数调用时实参可以是表的构造。rename{old="temp.lua", new="temp1.lua&q 阅读全文
posted @ 2014-03-01 18:30 一枚程序 阅读(1709) 评论(0) 推荐(0) 编辑

摘要: Lua函数可以接受可变数目的参数,和C语言类似在函数参数列表中使用三点(...)表示函数有可变的参数。Lua将函数的参数放在一个叫arg的表中,除了参数以外,arg表中还有一个域n表示参数的个数。例如,我们可以重写print函数:printResult = ""function print(...) for i,v in ipairs(arg) do printResult = printResult .. tostring(v) .. "\t" end printResult = printResult .. "\n"end有时候我 阅读全文
posted @ 2014-03-01 18:25 一枚程序 阅读(419) 评论(0) 推荐(0) 编辑

摘要: 5.1 多返回值Lua函数可以返回多个结果值,比如string.find,其返回匹配串“开始和结束的下标”(如果不存在匹配串返回nil)。s, e = string.find("hello Lua users", "Lua")print(s, e) --> 7 9Lua函数中,在return后列出要返回的值得列表即可返回多值,如:function maximum (a) local mi = 1 -- maximum index local m = a[mi] -- maximum value for i,val in ipairs(a) do i 阅读全文
posted @ 2014-03-01 17:40 一枚程序 阅读(606) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 26 下一页