Cocos2dx+lua基础ccb

我去,绑定狗屎的ccb文件,搞的我崩溃了!!


绑定ccb文件:

local proxy = CCBProxy:create();
        proxy:retain();
        local n = proxy:readCCBFromFile"MainCity/MainScene.ccbi";
        local layer = tolua.cast(n, "CCLayer");


绑定CCMenuItem事件:

        local mainCityButton = tolua.cast(proxy:getNodeWithType("mainCityButton","CCMenuItem"),"CCMenuItem")
        proxy:handleMenuEvent(mainCityButton,function()
            CCLuaLog("proxy:handleMenuEvent");
        end)


绑定CCControlButton事件:

        local button = tolua.cast(proxy:getNodeWithType("button","CCControlButton"),"CCControlButton")
        proxy:handleButtonEvent(button, function(s, e)
            CCLuaLog("proxy:handleButtonEvent");
        end, 0) -- 0 means UpInside


绑定label并显示:

tolua.cast(proxy:getNode"Label", "CCLabelTTF"):setString"This is a label."





你可能感兴趣的:(Cocos2dx+lua)