白日门用cocos creator制作UI 第三集 制作一个列表项目-白日门换皮论坛-教程-阿柳云网

白日门用cocos creator制作UI 第三集 制作一个列表项目

LUA_RET={
    {id=1,w=960,type=0,h=640,parent=0,n="PanelGongLue_tab3",},
    {x=573,ay=0.50,id=2,y=480,v=true,res="strategy_banner1",type=1,parent=1,w=697,ax=0.50,h=103,tag=1,n="ImageView_0",},
    {sw=193,sh=22,tag=413,v=true,res="render_bg",sy=21,sx=186,ss=true,n="rendBg",w=708,type=1,h=84,parent=6,id=7,},
    {olc="0,0,0,255",x=64,id=8,y=43,v=true,parent=6,fr=true,fs=20,ay=0.50,tag=414,text="",vt=1,ols=1,ht=0,w=250,type=3,h=25,n="labDesp",color="253|223|174",},
    {x=364,ay=0.50,id=9,y=42,v=true,parent=6,tag=415,type=1,w=68,ax=0.50,h=68,res="img_cell",n="icon1",},
    {x=559,sh=25,id=10,y=43,v=false,parent=6,tcolor="255|224|139",ax=0.50,fs=20,t=true,sw=90,ay=0.50,tag=416,ud="outline(076900,1);zoomscale(-0.12)",sx=15,text="领取奖励",sy=10,n="btnLing",sel="btn_green",w=120,ss=true,h=45,res="btn_green",type=2,},
    {x=560,ay=0.50,id=11,y=43,v=true,parent=6,tag=417,type=1,w=80,ax=0.50,h=76,res="img_has_got",n="imgYLQ",},
    {t=true,tag=412,y=285,v=true,parent=5,w=708,type=0,h=83,n="render",id=6,},
    {t=true,x=225,id=5,y=59,v=true,parent=1,ud="1|1|0|0",d=1,w=708,type=9,h=368,tag=411,n="awardsList",},
}

列表项目,如图所示

66d3e591b9182252

 

function PanelGongLue.updateLongXinData(data)
	-- PanelCelebrationAct.updateCount(var.xmlLongXin,data.time)
	-- local function prsBtnClick(sender)
		-- NetClient:PushLuaTable("gui.PanelCelebrationAct.onPanelData",util.encode({actionid = "reqLongXinAwards",params={index=sender.index}}))
	-- end

	local allUse = data.allUse
	local function updateList(item)
		local itemData = data.dataTable[item.tag]
		item:getWidgetByName("labDesp"):setString("使用"..itemData.name.."x"..itemData.useNum)
		for i=1,#itemData.awards do
			local award = itemData.awards[i]
			local awardItem=item:getWidgetByName("icon"..i)
			if award then
				awardItem:setVisible(true)
				local param={parent=awardItem, typeId=award.id, num=award.num}
				UIItem.getItem(param)
			else
				awardItem:setVisible(false)
			end
		end
		local btnLing = item:getWidgetByName("btnLing")
		local imgYlq = item:getWidgetByName("imgYLQ")
		if itemData.ling>0 then
			imgYlq:setVisible(true)
			btnLing:setVisible(false)
			btnLing:removeChildByName("img_bln")
		else
			imgYlq:setVisible(false)
			btnLing:setVisible(true)
			if allUse>=itemData.useNum then
				util.addHaloToButton(btnLing, "btn_normal_light3")
			else
				btnLing:removeChildByName("img_bln")
			end
		end
		btnLing.index=item.tag
		UIRedPoint.addUIPoint(btnLing,prsBtnClick)
	end

	local awardsList = var.xmlPageTab3:getWidgetByName("awardsList")
	awardsList:reloadData(#data.dataTable,updateList):setSliderVisible(false):setTouchEnabled(true)
end

function PanelGongLue.handlePanelData(event)
	--if event.type ~= "PanelCelebrationAct" then return end
	local data = util.decode(event.data)
	-- print(event.data)
	if data.cmd=="updateLongXinData" then
		PanelGongLue.updateLongXinData(data)

	end
end

 

请登录后发表评论

    没有回复内容