Bar Sprite:进度条显示用的Sprite节点。
Mode:进度条水平或者垂直
Total Length:进度条总长度
Progress:进度条的初始位置和进度
Reverse:是否将进度条反向驱动,开启后从左到右的进度条变成从右到做
两个小demo:
加载小鸟图片时候的进度条:
@property(cc.Sprite)
bird: cc.Sprite ;
@property(cc.ProgressBar)
birdProgressBar: cc.ProgressBar ;
start () {
this.bird.fillRange = 0;
cc.tween(this.bird)
.to(3,{fillRange:1}).start();
}
update(dt: number): void {
this.birdProgressBar.progress = this.bird.fillRange;
}
翻页时候的进度条:
protected update(dt: number): void {
//cc.log(this.myPageView.isAutoScrolling());
// this.myPageView.isAutoScrolling();
this.node.childrenCount;
this.myProgressBar.progress = ((this.myPageView.getCurrentPageIndex()+1)/this.node.getChildByName('view').getChildByName('content').childrenCount);
}