|
- cc.LoadingBar.ClassName = "LoadingBar"
-
- function cc.LoadingBar:saveToXmlNode(xmlNode)
- cc.Widget.saveToXmlNode(self , xmlNode);
-
- xmlNode.Texture = getUITexture(self:getTextureFile() , self:getRenderBarTexType());
- xmlNode.Scale9Enabled = self:isScale9Enabled();
- if xmlNode.Scale9Enabled then
- xmlNode.CapInsets = self:getCapInsets();
- end
-
- xmlNode.Direction = self:getDirection();
- xmlNode.Percent = self:getPercent();
-
- end
-
- function cc.LoadingBar:loadFromXmlNode(xmlNode)
- cc.Widget.loadFromXmlNode(self , xmlNode);
-
- setUITexture(self.loadTexture , self , xmlNode.Texture);
-
- self:setScale9Enabled(xmlNode.Scale9Enabled);
-
- if self:isScale9Enabled() then
- self:setCapInsets(xmlNode.CapInsets);
- end
-
- self:setDirection(xmlNode.Direction);
- self:setPercent(xmlNode.Percent);
- end
-
- function cc.LoadingBar:extend(node)
- cc.Widget:extend(node);
- node:setName("LoadingBar")
- end
-
- -- 把进度条以动画形式设置到percent值, isSineOut是否由快至慢
- function cc.LoadingBar:animPercent(targetPercent, duration, isSineOut, aniEndFunc)
- if not tolua.isnull(self.AnimPercentAction) then
- self:stopAction(self.AnimPercentAction);
- end
-
- local function actionEnd()
- if aniEndFunc then
- aniEndFunc()
- end
- end
-
- self.AnimPercentAction = nil;
- if isSineOut then
- if targetPercent ~= self:getPercent() then
- local action = cc.EaseSineOut:create(cc.UIPercentTo:create(duration , targetPercent));
- self.AnimPercentAction = action;
- self:runActions(action, actionEnd);
- else
- actionEnd()
- end
- else
- if targetPercent ~= self:getPercent() then
- local action = cc.UIPercentTo:create(duration , targetPercent);
- self.AnimPercentAction = action;
- self:runActions(action, actionEnd);
- else
- actionEnd()
- end
- end
- end
-
- function cc.LoadingBar:createNode()
- local layer = cc.LoadingBar:create();
- cc.LoadingBar:extend(layer);
- return layer;
- end
-
- -- 设置默认值
- function cc.LoadingBar:setDefaults()
- self:loadTexture("res/default/loadingbar.png");
- self:setCapInsets(cc.rect(0,0,0,0));
- self:setPercent(100);
- end
-
-
-
- -- 重新加载这个控件的所有图片
- function cc.LoadingBar:postloadImage()
- local isScale9 = self:isScale9Enabled();
- self:setScale9Enabled(not isScale9);
- self:setScale9Enabled(isScale9);
- end
-
- -- 收集这个控件用到了哪些PList文件
- function cc.LoadingBar:collectPListFiles()
- local files = {};
- collectPListFile(files , self:getTextureFile() , self:getRenderBarTexType());
-
- function getParent(node, path)
- local parent = node:getParent()
- if parent then
- local nameParent = parent:getName()
- path = nameParent.. "\\"..path
-
- return getParent(parent, path)
- else
- return path
- end
- end
-
- local nodePath = getParent(self, self:getName());
-
- for k,v in pairs(files) do
- print("plist = " .. v .. ", nodePath = ".. nodePath)
- end
-
- return files;
- end
|