Commit 0ea01a0c authored by 智慧's avatar 智慧

feat:将之前降落伞的拖拽进度条改成可点击来变换进度条

parent 82d8c429
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
"array": [ "array": [
0, 0,
0, 0,
477.1677545665711, 753.4294426550072,
0, 0,
0, 0,
0, 0,
...@@ -602,7 +602,7 @@ ...@@ -602,7 +602,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 884, "width": 880,
"height": 24 "height": 24
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -614,8 +614,8 @@ ...@@ -614,8 +614,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-3, 0,
-1, 0,
0, 0,
0, 0,
0, 0,
...@@ -667,7 +667,7 @@ ...@@ -667,7 +667,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 888, "width": 876,
"height": 24 "height": 24
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -679,7 +679,7 @@ ...@@ -679,7 +679,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-3, 0,
-13, -13,
0, 0,
0, 0,
...@@ -747,8 +747,8 @@ ...@@ -747,8 +747,8 @@
"alignMode": 1, "alignMode": 1,
"_target": null, "_target": null,
"_alignFlags": 40, "_alignFlags": 40,
"_left": -3, "_left": 0,
"_right": -1, "_right": 4,
"_top": 0, "_top": 0,
"_bottom": 0, "_bottom": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
......
...@@ -111,45 +111,55 @@ cc.Class({ ...@@ -111,45 +111,55 @@ cc.Class({
this.barTag.off(cc.Node.EventType.TOUCH_START); this.barTag.off(cc.Node.EventType.TOUCH_START);
this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => { this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
console.log("TOUCH_START"); console.log("TOUCH_START");
this.userDragStart = true;
this.triggerInteractive()
});
this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE,(e) => {
var delta = e.getDelta(); var delta = e.getDelta();
let newX = this.barTag.x+delta.x; let newX = this.barTag.x+delta.x;
newX = Math.min(maxX, Math.max(newX, minX)); newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX; this.barTag.width = newX;
const percent = newX / maxX; const percent = newX / maxX;
// console.log(newX, percent);
const dur = this.videoPlayer.getDuration(); const dur = this.videoPlayer.getDuration();
// this.videoPlayer.currentTime = percent * dur
// this.updateBarByPos(this.barTag.x);
this.currentTimeLabel.string = this.formatTime(percent * dur ); this.currentTimeLabel.string = this.formatTime(percent * dur );
this.triggerInteractive()
});
this.barTag.off(cc.Node.EventType.TOUCH_ENDED);
this.barTag.on(cc.Node.EventType.TOUCH_ENDED, (e) => {
console.log("TOUCH_ENDED");
this.userDragStart = false;
this.updateBarByPos(this.barTag.x);
this.triggerInteractive()
});
this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
console.log("MOUSE_UP");
this.userDragStart = false;
this.updateBarByPos(this.barTag.x); this.updateBarByPos(this.barTag.x);
this.triggerInteractive() this.triggerInteractive()
}); });
// this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
// this.barTag.on(cc.Node.EventType.TOUCH_MOVE,(e) => {
// var delta = e.getDelta();
// let newX = this.barTag.x+delta.x;
// newX = Math.min(maxX, Math.max(newX, minX));
// this.barTag.width = newX;
// const percent = newX / maxX;
// // console.log(newX, percent);
// const dur = this.videoPlayer.getDuration();
// // this.videoPlayer.currentTime = percent * dur
// // this.updateBarByPos(this.barTag.x);
// this.currentTimeLabel.string = this.formatTime(percent * dur );
// this.triggerInteractive()
// });
// this.barTag.off(cc.Node.EventType.TOUCH_ENDED);
// this.barTag.on(cc.Node.EventType.TOUCH_ENDED, (e) => {
// console.log("TOUCH_ENDED");
// this.userDragStart = false;
// this.updateBarByPos(this.barTag.x);
// this.triggerInteractive()
// });
// this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
// console.log("MOUSE_UP");
// this.userDragStart = false;
// this.updateBarByPos(this.barTag.x);
// this.triggerInteractive()
// });
this.barTag.off(cc.Node.EventType.TOUCH_CANCEL); // this.barTag.off(cc.Node.EventType.TOUCH_CANCEL);
this.barTag.on(cc.Node.EventType.TOUCH_CANCEL, (e) => { // this.barTag.on(cc.Node.EventType.TOUCH_CANCEL, (e) => {
console.log("TOUCH_CANCEL"); // console.log("TOUCH_CANCEL");
this.userDragStart = false; // this.userDragStart = false;
this.updateBarByPos(this.barTag.x); // this.updateBarByPos(this.barTag.x);
this.triggerInteractive() // this.triggerInteractive()
}); // });
this.ProgressBar.node.off(cc.Node.EventType.TOUCH_START); this.ProgressBar.node.off(cc.Node.EventType.TOUCH_START);
this.ProgressBar.node.on(cc.Node.EventType.TOUCH_START, (e) => { this.ProgressBar.node.on(cc.Node.EventType.TOUCH_START, (e) => {
const pos = e.getLocation(); const pos = e.getLocation();
...@@ -158,15 +168,15 @@ cc.Class({ ...@@ -158,15 +168,15 @@ cc.Class({
this.updateBarByPos(newX); this.updateBarByPos(newX);
// console.log("ProgressBar TOUCH_START", newX); // console.log("ProgressBar TOUCH_START", newX);
}); });
this.node.off(cc.Node.EventType.TOUCH_START); // this.node.off(cc.Node.EventType.TOUCH_START);
this.node.on(cc.Node.EventType.TOUCH_START, (e) => { // this.node.on(cc.Node.EventType.TOUCH_START, (e) => {
console.log("screen TOUCH_START"); // console.log("screen TOUCH_START");
this.triggerInteractive() // this.triggerInteractive()
}); // });
const pgBar = this.ProgressBar.node; const pgBar = this.ProgressBar.node;
this.tw = new (function(){ this.tw = new (function(){
this._tw = cc.tween(pgBar).delay(3).to(.6, { this._tw = cc.tween(pgBar).delay(3).to(.6, {
opacity: 0 opacity: 255
}).call(() => { }).call(() => {
console.log('This is a callback'); console.log('This is a callback');
this.running = false; this.running = false;
...@@ -191,7 +201,7 @@ cc.Class({ ...@@ -191,7 +201,7 @@ cc.Class({
} }
}); });
this.tw = cc.tween(this.ProgressBar.node).delay(3).to(.6, { this.tw = cc.tween(this.ProgressBar.node).delay(3).to(.6, {
opacity: 0 opacity: 255
}).call(() => { }).call(() => {
console.log('This is a callback'); console.log('This is a callback');
// this.tw.stop(); // this.tw.stop();
...@@ -262,7 +272,7 @@ cc.Class({ ...@@ -262,7 +272,7 @@ cc.Class({
const minX = 0; const minX = 0;
let newX = percent * maxX; let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX)); newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX; this.barTag.width = newX;
}, },
formatTime(time) { formatTime(time) {
if (time === undefined) { if (time === undefined) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment