[Lua]基於cc.load('mvc') .ViewBase索引資源方案

來源:互聯網
上載者:User

標籤:

local MainScene = class("MainScene", cc.load("mvc").ViewBase)MainScene.RESOURCE_FILENAME = "MainScene.csb"function MainScene:nodeFromPath(path, root)    root = root or self:getResourceNode()    assert(root, ‘need root node‘)    local nn = string.split(path, ‘.‘)    local node = root    for i = 1, #nn do        node = node:getChildByName(nn[i])    end    return nodeendfunction MainScene:indexResource(parent, map)    assert(parent, ‘need parent node‘)    for key, name in pairs(map) do        self[key] = parent:getChildByName(name)    end    return selfendfunction MainScene:onCreate()    printf("resource node = %s", tostring(self:getResourceNode()))    self:indexResource(self:nodeFromPath(‘ProjectNode_1.BottomBar.Pc_Bg_4‘),    {        BtnAltar=‘BtnAltar_4‘;        BtnLvl=‘BtnLvl_6‘;        BtnPVP=‘BtnPVP_8‘;        BtnShop=‘BtnShop_10‘;        BtnFrd=‘BtnFrd_12‘;        BtnSetting=‘BtnSetting_14‘    })    self.BtnSetting:onTouch(handler(self, self.onSettingClicked))endfunction MainScene:onSettingClicked(event)    dump(event, ‘onSetting‘)endreturn MainScene

 

以上基於cocos 樣本MainMenu的指令碼修改。

[Lua]基於cc.load('mvc') .ViewBase索引資源方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.