zoukankan      html  css  js  c++  java
  • cocos2dx tableView 的使用

                ---创建tabView
                ---@param size {number,height:number}
                ---@param funcMap TabViewFuncMap
                ---@return TableView
                local function create_tableView(size, funcMap)
                    local tableView = cc.TableView:create(size)
                    tableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL)
                    tableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN)
                    tableView:setDelegate()
                    tableView:setAnchorPoint(0, 1)
                    tableView:registerScriptHandler(funcMap.NUMBER_OF_CELLS_IN_TABLEVIEW, cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
                    tableView:registerScriptHandler(funcMap.SCROLLVIEW_SCRIPT_SCROLL, cc.SCROLLVIEW_SCRIPT_SCROLL)
                    tableView:registerScriptHandler(funcMap.TABLECELL_TOUCHED, cc.TABLECELL_TOUCHED)
                    tableView:registerScriptHandler(funcMap.TABLECELL_SIZE_FOR_INDEX, cc.TABLECELL_SIZE_FOR_INDEX)
                    tableView:registerScriptHandler(funcMap.TABLECELL_SIZE_AT_INDEX, cc.TABLECELL_SIZE_AT_INDEX)
                    return tableView
                end
    
    
                local function createTabView(size)
                    local function scrollViewDidScroll1(view)
                        -- print("=========  scrollViewDidScroll1 滚动事件")
                       
                    end
                    local function tableCellTouched(table, cell)
                        -- print("=========  tableCellTouched  单元格点击事件")
                    end
                    ---@param table TableView
                    local function cellSizeForTable(table, idx)
                        -- print("=========  cellSizeForTable  单元格大小事件")
                        return 100, 100
                    end
                    ---@param table TableView
                    local function tableCellAtIndex(table, idx)
                        local index = idx + 1
                        local tabel_cell = table:dequeueCell()
                        -- print("=========  tableCellAtIndex  单元格创建事件", index)
            
                        ---使用缓存池不使用分帧的方式
                        local function usePoolNoFenZhen()
                            local data = self.chat_data[index]
                            --初始化
                            if nil == tabel_cell then
                                tabel_cell = cc.TableViewCell:new()
                                local itemCom = self:get_chat_item_by_data(data, index)
                                tabel_cell:addChild(itemCom.view)
                            else
                                tabel_cell:removeAllChildren()
                                ---@type ChatListItem|ChatNotice
                                local itemCom = self:get_chat_item_by_data(data, index)
                                itemCom:update_all(data, self.channel)
                                tabel_cell:addChild(itemCom.view)
                            end
                            return tabel_cell
                        end
            
                        local tabel_cell = usePoolNoFenZhen()
                        return tabel_cell
                    end
                    local function numberOfCellsInTableView(table)
                        -- print("=========  numberOfCellsInTableView  单元格数量")
                        local dataLen = #self.chat_data
                        return dataLen
                    end
            
                    local funcMap = TabViewFuncMapSS()
                    funcMap.NUMBER_OF_CELLS_IN_TABLEVIEW = numberOfCellsInTableView
                    funcMap.SCROLLVIEW_SCRIPT_SCROLL = scrollViewDidScroll1
                    funcMap.TABLECELL_TOUCHED = tableCellTouched
                    funcMap.TABLECELL_SIZE_FOR_INDEX = cellSizeForTable
                    funcMap.TABLECELL_SIZE_AT_INDEX = tableCellAtIndex
                    local tableView = create_tableView(size, funcMap)
            
                    return tableView
                end
  • 相关阅读:
    java环境变量的配置
    usb转串口驱动时会出现“文件的哈希值不在指定的目录”这样的提示
    虚拟机安装tools for Ubuntu
    ubuntu 修改root密码
    旺旺自动回复
    android 启动流程
    ASCII 码表
    电脑中快速查找东西
    appengine 云计算。 部署web网络。
    openssl-0.9.8k_WIN32(RSA密钥生成工具
  • 原文地址:https://www.cnblogs.com/dmc-nero/p/14184732.html
Copyright © 2011-2022 走看看