mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 09:32:38 +08:00
Merge pull request #343 from zilongshanren/addProgressBarReverse
add progress bar reverse support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user