cocos2dx之商店源码
发布时间:2020-12-14 16:20:57 所属栏目:百科 来源:网络整理
导读:function shopLayer.initShopGoods(iTabelIndex) -- body print("---- Enter shopLayer.initShopGoods ----") --高亮选中项 shopLayer._shopTabel[iTabelIndex]._Selected:setVisible(true) shopLayer._shopTabel[iTabelIndex]._Normal:setVisible(false) if
function shopLayer.initShopGoods(iTabelIndex) -- body print("---- Enter shopLayer.initShopGoods ----") --高亮选中项 shopLayer._shopTabel[iTabelIndex]._Selected:setVisible(true) shopLayer._shopTabel[iTabelIndex]._Normal:setVisible(false) if shopLayer._shopTabel[iTabelIndex]._Panel ~= nil and shopLayer._ListView ~= nil then --todo --商店总共6项 ,这个值可以随意变化 local panelMode = shopLayer._shopTabel[iTabelIndex]._Panel shopLayer._ListView:setItemModel(panelMode) for i = 1,6 do shopLayer._ListView:pushBackDefaultItem() end local ViewWidth = shopLayer._ListView:getContentSize().width local iID = shopLayer._shopTabel[iTabelIndex]._id print("iID: "..iID) for i = 0,5 do --lua里面ListView是从0开始的 local iItem = shopLayer._ListView:getItem(i) local btnResID = shopLayer._ButtonRes[iID][i + 1].buy_btn local btn = ccui.Button:create(btnResID) local itemHeight = iItem:getContentSize().height btn:setPosition(ViewWidth - btn:getContentSize().width / 2,itemHeight / 2) btn:setAnchorPoint(cc.p(0.5,0.5)) btn:setTouchEnabled(true) btn.shopType = iTabelIndex; --商店类型 btn.id = i + 1 --商店按钮ID btn:addTouchEventListener(function (sender,eventType) --这里回调到每个按钮所对应的信息 -- body if eventType == 2 then --todo local CostType = sender.shopType local CostID = sender.id local iCount = shopLayer._ButtonRes[CostType][CostID].count if sender.shopType == 1 then --萌币 cpp_SaveBudCoinCount(iCount) print("shopType ____1,Button ID: "..sender.id) else print("shopType ____2,Button ID: "..sender.id) end end end) iItem:addChild(btn) end end print("---- Exit shopLayer.initShopGoods ----") end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |