—设置叠加模式,高亮 setBlend=function(sp,ctype) local blendType={ {GL_ONE,GL_ONE_MINUS_SRC_ALPHA}, {GL_SRC_ALPHA,GL_ONE} } local cc=ccBlendFunc(); cc.src=blendType[ctype][1]; cc.dst=blendType[ctype][2]; sp:setBlendFunc(cc); end
—赋值变量 function nvl(var,value) if var==nil then return value; else return var; end end
—延迟任务 setTimeout=function(timeout,fn) local cs=CCDirector::sharedDirector():getRunningScene(); if cs~=nil then local wait=CCDelayTime::create(timeout); local arr=CCArray:create(); arr:addObject(wait); arr:addObject(CCCallFuncN:create(funtion() fn(); end )); local seq=CCSequence:create(arr); cs:runAction(seq); end
—分割字符串 local split=function(s,p) local rt={} string.gsub(s, ‘[^’..p..’]+’, function(w) table.insert(rt,w); end); return rt; end
—action+callfun runAction=function(node,action,fn) if fn~=nil then local act=CCSequence:createWithTwoActions(action,CCCallFuncN:create( function() fn(); end)); else node:runAction(action); end end
时间: 2024-12-14 08:35:32