首页 > 代码库 > cocos2d-x-lua基础系列教程一(hello lua)

cocos2d-x-lua基础系列教程一(hello lua)

myscene.lua

function ERROR_TRACBACK(msg)
 print (==========)
 print ("lua error is "..tostring(msg))
 print (debug.traceback())
 print ("=========")
end

cclog = function (…)
 print(string.format(...))
end

CCSize winsize = CCDirector:shareDirector():getWinSize()


------入口方法
function main()
  cclog("entrn ")
 
local bgSprite = CCSprite:create("HelloWorld.png");

   local scene = CCScene:create();
bgSprite:setposition(winsize.width*0.5,winsize.height*0.5)

local bglayer = cclayer:create()
bglayer:addchild(bgsprite())

  CCDirector:shareDirector():runWithScene(scene)
end
addChild(bglayer)
xpcall(main,ERROR_TRACBACK)


cocos2d-x-lua基础系列教程一(hello lua)