在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
-- 这里要注意的点是:虽然nAmount是局部变量,却在控件的响应函数中使用 -- 因为控件的响应函数是在该变量的区域内,所以可以用 -- 如果控件的响应函数在外部,那么该变量就要声明成为全局变量 function UIBagController:showUse( ) -- 赋值属性 local nAmount = self.item.pileCount; local imageViewItem = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "ImageView_Item"), "ImageView"); local labelItemDsc = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "Label_ItemDsc"), "Label"); local lebGNum = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "lebGNum"), "Label"); local btnNumDes = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "btnNumDes"), "Button"); local btnGNumAdd = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "btnGNumAdd"), "Button"); local btnMax = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "btnMax"), "Button"); lebGNum:setText(nAmount .. "/99"); btnNumDes:addTouchEventListener(function ( uiwidget, eventType ) if eventType == TOUCH_EVENT_ENDED then -- 数字减少 if nAmount > 1 then nAmount = nAmount - 1; lebGNum:setText(nAmount .. "/99"); end end; end); btnGNumAdd:addTouchEventListener(function ( uiwidget, eventType ) if eventType == TOUCH_EVENT_ENDED then -- 数字增加 if nAmount < self.item.pileCount then nAmount = nAmount + 1; lebGNum:setText(nAmount .. "/99"); end end; end); btnMax:addTouchEventListener(function ( uiwidget, eventType ) if eventType == TOUCH_EVENT_ENDED then -- 数字直接到最大 lebGNum:setText(self.item.pileCount .. "/99"); end; end); imageViewItem:loadTexture(self.item:getIconPath()); labelItemDsc:setText(self.item:getDsc()); self:setLabelFont(labelItemDsc) local labelItenNum = tolua.cast(UIHelper:seekWidgetByName(self.panelUse, "Label_ItenNum"), "Label"); self:showItemNum(self.item, labelItenNum) self.panelUse:setVisible(true) self.panelUse:setEnabled(true); self.panelUse:setTouchEnabled(true); self:hideDetail() self:hideSell() end
|
请发表评论