1、先创建一个Sprite图片02_horizontal_bar_reverse
2、再创建一个进度条控件02_horizontal_reverse
3、设置进度条属性,关联精灵Sprite图片02_horizontal_bar_reverse,滚动到的位置和是否反转
4、创建一个脚本,设置进度条属性
horizontalBarReverse: {
type: cc.ProgressBar,
default: null
},
5、关联控件02_horizontal_bar_reverse
6、脚本设置进度条的进度
onLoad: function () {
this.horizontalBar.progress = 0;
},
update: function (dt) {
this._updateProgressBar(this.horizontalBar, dt);
},
_updateProgressBar: function(progressBar, dt){
var progress = progressBar.progress;
if(progress < 1.0){
progress += dt * this.speed;
}
else {
progress -= dt * this.speed;
}
progressBar.progress = progress;
}