zoukankan      html  css  js  c++  java
  • 每帧创建一个item

    -- 加载列表测试
    function UIBagController:onLoadTest()
        self.goodsprop = DB.getTable("goodsprop");
        
        local itemAmount = 50;
        -- 计算高度
        local nAmount = 0;
        if itemAmount % self.m_nRColumn == 0 then
            nAmount = math.modf( itemAmount / self.m_nRColumn );
        else
            nAmount = math.modf( itemAmount / self.m_nRColumn + 1 );
        end
        local nHeigh = nAmount * self.m_nHeigh;
        self.m_nInnerHeigh = nHeigh;
        local size = self.scrollPanel:getInnerContainerSize();
        if nHeigh < size.height then
            nHeigh = size.height;
        end
        self.scrollPanel:setInnerContainerSize(CCSizeMake(size.width, nHeigh));
        --print("==宽高==" .. size.width .. " " .. nHeigh)
        local nWidth = size.width;
        local nPosX = 0;
        local nPosY = 0;
        local nIndex = 0;
        nHeigh = nHeigh - self.m_nHeigh;
        local nItemWidth = size.width / self.m_nRColumn;
        if itemAmount ~= nil then
            self.ScheduleId = CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(function ( )
                print("nIndex " .. nIndex)
                print("itemAmount " .. itemAmount)
                if nIndex >= itemAmount then
                    CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry(self.ScheduleId);
                end
                local info = self.goodsprop[nIndex + 1];
                local item = self.ImageView_item:clone();
                if nIndex % self.m_nRColumn == 0 then
                    nPosY = nHeigh - math.modf(nIndex / self.m_nRColumn) * self.m_nHeigh;
                    local itemSize = item:getSize();
                    nPosY = nPosY + itemSize.height / 2;
                end
                nPosX = self.m_nPosXStart + math.ceil(nIndex % self.m_nRColumn) * nItemWidth;
                item:setPosition(ccp(nPosX, nPosY));
                item:setVisible(true);
                self.scrollPanel:addChild(item);
                self:loadItem(item);
    
                nIndex = nIndex + 1;
            end, 0, false); 
        end
    end
    
    -- 加载数据
    function UIBagController:loadItem(uiwidget)
        local imgItem = tolua.cast(UIHelper:seekWidgetByName(uiwidget, "ImageView_Item"), "ImageView");
        imgItem:loadTexture(ItemM:getIconPath(21419))
    end
  • 相关阅读:
    [OpenJudge90][序列DP+乱搞]滑雪
    [OpenJudge8786][暴力DP]方格取数
    [OpenJudge8782][划分DP]乘积最大
    [OpenJudge8471][划分DP]切割回文
    [OpenJudge8462][序列DP]大盗阿福
    【棋盘DP】【OpenJudge7614】最低通行费
    【OpenJudge8464】【序列DP】股票买卖
    bzoj1674: [Usaco2005]Part Acquisition 裸dijkstra
    bzoj3040 最短路+配对堆优化
    poj1330|bzoj3732|noip2013 货车运输 kruskal+倍增lca
  • 原文地址:https://www.cnblogs.com/newlist/p/4098109.html
Copyright © 2011-2022 走看看