-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadingBarScene.js
More file actions
52 lines (51 loc) · 1.62 KB
/
LoadingBarScene.js
File metadata and controls
52 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var LoadingLayer = cc.Layer.extend({
_loadingBar:null,
_count:0,
ctor:function(){
this._super();
this._count = 0;
var size = cc.winSize;
this.createLoadingBar();
this.scheduleUpdate();
var nextButton = new ccui.Button();
nextButton.setTouchEnabled(true);
nextButton.loadTextures("res/backtotopnormal.png", "res/backtotoppressed.png", "");
nextButton.setTitleText("停止");
nextButton.x = size.width /4.0*3;
nextButton.y = size.height / 4.0;
nextButton.addTouchEventListener(this.touchEvent ,this);
this.addChild(nextButton);
},
createLoadingBar:function(){
var widgetSize = cc.winSize;
var loadingBar = new ccui.LoadingBar();
loadingBar.setName("LoadingBar");
loadingBar.loadTexture("res/sliderProgress.png");
loadingBar.setPercent(0);
loadingBar.x = widgetSize.width / 2;
loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4;
this.addChild(loadingBar);
this._loadingBar = loadingBar;
},
update:function(dt){
this._count++;
if (this._count > 100) {
this._count = 0;
}
this._loadingBar && this._loadingBar.setPercent(this._count);
},
touchEvent: function (sender, type) {
switch (type) {
case ccui.Widget.TOUCH_ENDED:
cc.log("Stop clicked!");
this.unscheduleUpdate();
}
}
});
var LoadingBarScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new LoadingLayer();
this.addChild(layer);
}
});