Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了cocos2dx之商店源码大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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

大佬总结

以上是大佬教程为你收集整理的cocos2dx之商店源码全部内容,希望文章能够帮你解决cocos2dx之商店源码所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。