Merge pull request #343 from zilongshanren/addProgressBarReverse

add progress bar reverse support
This commit is contained in:
Jare Guo
2016-02-19 09:42:31 +08:00
2 changed files with 10 additions and 7 deletions
+8 -5
View File
@@ -38,9 +38,9 @@ var Mode = cc.Enum({
*/
VERTICAL: 1,
/**
* @property {Number} RADIAL
* @property {Number} FILLED
*/
RADIAL: 2,
FILLED: 2,
});
/**
@@ -71,7 +71,7 @@ var ProgressBar = cc.Class({
}
if (this.barSprite.fillType === cc.Sprite.FillType.RADIAL) {
this.mode = Mode.RADIAL;
this.mode = Mode.FILLED;
}
var barSpriteSize = entity.getContentSize();
@@ -127,7 +127,10 @@ var ProgressBar = cc.Class({
totalWidth = entitySize.width;
totalHeight = this.totalLength;
break;
case Mode.RADIAL:
case Mode.FILLED:
if (this.reverse) {
actualLenth = actualLenth * -1;
}
this.barSprite.fillRange = actualLenth;
break;
}
@@ -181,7 +184,7 @@ var ProgressBar = cc.Class({
this.totalLength = entitySize.width;
} else if (this.mode === Mode.VERTICAL) {
this.totalLength = entitySize.height;
} else if (this.mode === Mode.RADIAL) {
} else if (this.mode === Mode.FILLED) {
this.totalLength = this.barSprite.fillRange;
}
}
+2 -2
View File
@@ -170,7 +170,7 @@ var Sprite = cc.Class({
return this._fillStart;
},
set: function(value) {
this._fillStart = cc.clamp01(value);
this._fillStart = cc.clampf(value, -1, 1);
this._sgNode && this._sgNode.setFillStart(value);
},
},
@@ -180,7 +180,7 @@ var Sprite = cc.Class({
return this._fillRange;
},
set: function(value) {
this._fillRange = cc.clamp01(value);
this._fillRange = cc.clampf(value, -1, 1);
this._sgNode && this._sgNode.setFillRange(value);
},
},