Commit d38b7c43 authored by Tt's avatar Tt

拖拽组件完成

parent 734492a0
......@@ -84,22 +84,22 @@
"__id__": 151
},
{
"__id__": 183
"__id__": 190
},
{
"__id__": 203
"__id__": 210
}
],
"_active": true,
"_components": [
{
"__id__": 205
"__id__": 212
},
{
"__id__": 206
"__id__": 213
},
{
"__id__": 207
"__id__": 214
}
],
"_prefab": null,
......@@ -5558,18 +5558,27 @@
},
{
"__id__": 164
},
{
"__id__": 166
},
{
"__id__": 168
},
{
"__id__": 180
}
],
"_active": true,
"_components": [
{
"__id__": 180
"__id__": 187
},
{
"__id__": 181
"__id__": 188
},
{
"__id__": 182
"__id__": 189
}
],
"_prefab": null,
......@@ -6204,29 +6213,213 @@
},
{
"__type__": "cc.Node",
"_name": "slider",
"_name": "lb_time1",
"_objFlags": 0,
"_parent": {
"__id__": 151
},
"_children": [
"_children": [],
"_active": true,
"_components": [
{
"__id__": 165
},
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 97.87,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
719.777,
-458.136,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b009S4eI5EXaEc9ztwMKXe"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 164
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Label",
"_N$string": "Label",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "d4f1dAAYBFRbEfU0ypBSO6"
},
{
"__type__": "cc.Node",
"_name": "lb_time2",
"_objFlags": 0,
"_parent": {
"__id__": 151
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 167
},
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 97.87,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
718.828,
-503.86,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "4aS8QxmyhIvaRwQrWhuDa6"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 166
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Label",
"_N$string": "Label",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "98VR4VOi5G25on2d+UgJrh"
},
{
"__type__": "cc.Node",
"_name": "slider",
"_objFlags": 0,
"_parent": {
"__id__": 151
},
"_children": [
{
"__id__": 169
},
{
"__id__": 173
"__id__": 171
},
{
"__id__": 175
"__id__": 173
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 177
......@@ -6291,13 +6484,13 @@
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 164
"__id__": 168
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 166
"__id__": 170
}
],
"_prefab": null,
......@@ -6353,7 +6546,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 165
"__id__": 169
},
"_enabled": true,
"_materials": [
......@@ -6385,13 +6578,13 @@
"_name": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 164
"__id__": 168
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 168
"__id__": 172
}
],
"_prefab": null,
......@@ -6447,7 +6640,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 167
"__id__": 171
},
"_enabled": true,
"_materials": [
......@@ -6479,17 +6672,17 @@
"_name": "Handle",
"_objFlags": 0,
"_parent": {
"__id__": 164
"__id__": 168
},
"_children": [
{
"__id__": 170
"__id__": 174
}
],
"_active": true,
"_components": [
{
"__id__": 172
"__id__": 176
}
],
"_prefab": null,
......@@ -6545,13 +6738,13 @@
"_name": "Handle copy",
"_objFlags": 0,
"_parent": {
"__id__": 169
"__id__": 173
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 171
"__id__": 175
}
],
"_prefab": null,
......@@ -6607,7 +6800,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 170
"__id__": 174
},
"_enabled": true,
"_materials": [
......@@ -6639,7 +6832,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 169
"__id__": 173
},
"_enabled": true,
"_normalMaterial": {
......@@ -6714,49 +6907,131 @@
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 169
"__id__": 173
},
"_id": "b6AurW2UZMu6klj5I0iivx"
},
{
"__type__": "cc.Node",
"_name": "lb_time1",
"__type__": "cc.Slider",
"_name": "",
"_objFlags": 0,
"_parent": {
"__id__": 164
"node": {
"__id__": 168
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 174
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"_enabled": true,
"direction": 0,
"slideEvents": [],
"_N$handle": {
"__id__": 176
},
"_N$progress": 0.2,
"_id": "94vlNB86NGBo0zzT7ycqox"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 168
},
"_enabled": false,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "667a35fb-fe5c-44cf-b101-6623785e1786"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "0c4wlBvwdElbQvZ88/k7L6"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 168
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 20,
"_left": 454.086,
"_right": 0,
"_top": 0,
"_bottom": 68.305,
"_verticalCenter": 0,
"_horizontalCenter": -55.402000000000044,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "3dSPJZVOFPPa9OcbVmVVLr"
},
{
"__type__": "cc.Node",
"_name": "ProgressBar",
"_objFlags": 0,
"_parent": {
"__id__": 151
},
"_children": [
{
"__id__": 181
}
],
"_active": true,
"_components": [
{
"__id__": 185
},
{
"__id__": 186
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 97.87,
"height": 50.4
"width": 1388,
"height": 12
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1469.179,
7.559,
-748.719,
-465.866,
0,
0,
0,
......@@ -6778,53 +7053,86 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b009S4eI5EXaEc9ztwMKXe"
"_id": "bdLSz4g/lCwJGD4OeENaIL"
},
{
"__type__": "cc.Label",
"_name": "",
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 0,
"node": {
"__id__": 173
"_parent": {
"__id__": 180
},
"_enabled": true,
"_materials": [
"_children": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
"__id__": 182
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Label",
"_N$string": "Label",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "d4f1dAAYBFRbEfU0ypBSO6"
"_active": true,
"_components": [
{
"__id__": 184
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1388,
"height": 12
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "54+Qb0lSxMhruqqoMNIwGp"
},
{
"__type__": "cc.Node",
"_name": "lb_time2",
"_name": "bar_tag",
"_objFlags": 0,
"_parent": {
"__id__": 164
"__id__": 181
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 176
"__id__": 183
}
],
"_prefab": null,
......@@ -6838,8 +7146,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 97.87,
"height": 50.4
"width": 56,
"height": 56
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -6850,8 +7158,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1468.23,
-38.165,
0,
0,
0,
0,
0,
......@@ -6873,14 +7181,14 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "4aS8QxmyhIvaRwQrWhuDa6"
"_id": "52oCI7ktdHZqTozXMeojwz"
},
{
"__type__": "cc.Label",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 175
"__id__": 182
},
"_enabled": true,
"_materials": [
......@@ -6890,46 +7198,61 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Label",
"_N$string": "Label",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "98VR4VOi5G25on2d+UgJrh"
"_spriteFrame": {
"__uuid__": "8a399ec0-aa9c-4fe5-b990-a4355ddc9caf"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "5bBw1gHX9IxpWIB6/Dn+5S"
},
{
"__type__": "cc.Slider",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 164
"__id__": 181
},
"_enabled": true,
"direction": 0,
"slideEvents": [],
"_N$handle": {
"__id__": 172
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "dd6a0f64-6c2e-4c04-9140-4868932ea99a"
},
"_N$progress": 0.2,
"_id": "94vlNB86NGBo0zzT7ycqox"
"_type": 3,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "72eBD/O11JpKgJirL6jHB+"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 164
"__id__": 180
},
"_enabled": true,
"_materials": [
......@@ -6942,7 +7265,7 @@
"_spriteFrame": {
"__uuid__": "667a35fb-fe5c-44cf-b101-6623785e1786"
},
"_type": 0,
"_type": 1,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
......@@ -6954,34 +7277,24 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "0c4wlBvwdElbQvZ88/k7L6"
"_id": "89KOwr5+5KKrpSChygkBTY"
},
{
"__type__": "cc.Widget",
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 164
"__id__": 180
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 20,
"_left": 454.086,
"_right": 0,
"_top": 0,
"_bottom": 68.305,
"_verticalCenter": 0,
"_horizontalCenter": -55.402000000000044,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "3dSPJZVOFPPa9OcbVmVVLr"
"_N$totalLength": 1,
"_N$barSprite": {
"__id__": 184
},
"_N$mode": 2,
"_N$progress": 0,
"_N$reverse": false,
"_id": "64BH/Gec5Jua/knu9fDN7y"
},
{
"__type__": "cc.Widget",
......@@ -7025,16 +7338,22 @@
"__id__": 160
},
"vidoSlider": {
"__id__": 177
"__id__": 186
},
"ProgressBar": {
"__id__": 180
},
"playbar": {
"__id__": 167
"__id__": 171
},
"nowTime": {
"__id__": 174
"__id__": 165
},
"totalTime": {
"__id__": 176
"__id__": 167
},
"barTag": {
"__id__": 182
},
"_id": "40uKOXbmdKqIs73UDwwRGu"
},
......@@ -7057,13 +7376,13 @@
},
"_children": [
{
"__id__": 184
"__id__": 191
},
{
"__id__": 189
"__id__": 196
},
{
"__id__": 190
"__id__": 197
}
],
"_active": true,
......@@ -7121,14 +7440,14 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__": 183
"__id__": 190
},
"_children": [
{
"__id__": 185
"__id__": 192
},
{
"__id__": 187
"__id__": 194
}
],
"_active": true,
......@@ -7186,13 +7505,13 @@
"_name": "BRLNSDB",
"_objFlags": 0,
"_parent": {
"__id__": 184
"__id__": 191
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 186
"__id__": 193
}
],
"_prefab": null,
......@@ -7248,7 +7567,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 185
"__id__": 192
},
"_enabled": true,
"_materials": [
......@@ -7283,13 +7602,13 @@
"_name": "MuliBold",
"_objFlags": 0,
"_parent": {
"__id__": 184
"__id__": 191
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 188
"__id__": 195
}
],
"_prefab": null,
......@@ -7345,7 +7664,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 187
"__id__": 194
},
"_enabled": true,
"_materials": [
......@@ -7380,7 +7699,7 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 183
"__id__": 190
},
"_children": [],
"_active": true,
......@@ -7438,26 +7757,26 @@
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 183
"__id__": 190
},
"_children": [
{
"__id__": 191
"__id__": 198
},
{
"__id__": 193
"__id__": 200
},
{
"__id__": 195
"__id__": 202
},
{
"__id__": 197
"__id__": 204
},
{
"__id__": 199
"__id__": 206
},
{
"__id__": 201
"__id__": 208
}
],
"_active": true,
......@@ -7515,13 +7834,13 @@
"_name": "dispear",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 192
"__id__": 199
}
],
"_prefab": null,
......@@ -7577,7 +7896,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 191
"__id__": 198
},
"_enabled": true,
"_clip": {
......@@ -7596,13 +7915,13 @@
"_name": "right",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 194
"__id__": 201
}
],
"_prefab": null,
......@@ -7658,7 +7977,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 193
"__id__": 200
},
"_enabled": true,
"_clip": {
......@@ -7677,13 +7996,13 @@
"_name": "wrong",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 196
"__id__": 203
}
],
"_prefab": null,
......@@ -7739,7 +8058,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 195
"__id__": 202
},
"_enabled": true,
"_clip": {
......@@ -7758,13 +8077,13 @@
"_name": "lose",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 198
"__id__": 205
}
],
"_prefab": null,
......@@ -7820,7 +8139,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 197
"__id__": 204
},
"_enabled": true,
"_clip": {
......@@ -7839,13 +8158,13 @@
"_name": "win",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 200
"__id__": 207
}
],
"_prefab": null,
......@@ -7901,7 +8220,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 199
"__id__": 206
},
"_enabled": true,
"_clip": {
......@@ -7920,13 +8239,13 @@
"_name": "btn",
"_objFlags": 0,
"_parent": {
"__id__": 190
"__id__": 197
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 202
"__id__": 209
}
],
"_prefab": null,
......@@ -7982,7 +8301,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 201
"__id__": 208
},
"_enabled": true,
"_clip": {
......@@ -8007,7 +8326,7 @@
"_active": true,
"_components": [
{
"__id__": 204
"__id__": 211
}
],
"_prefab": null,
......@@ -8063,7 +8382,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 203
"__id__": 210
},
"_enabled": true,
"alignMode": 1,
......@@ -8148,7 +8467,7 @@
"__id__": 151
},
"touchlayer": {
"__id__": 203
"__id__": 210
},
"root_game": {
"__id__": 143
......
......@@ -16,8 +16,10 @@ export default class videoCtrl extends cc.Component {
@property(cc.Node)
vidoStateIcon: cc.Node = null;
@property(cc.Slider)
vidoSlider: cc.Slider = null;
@property(cc.ProgressBar)
vidoSlider: cc.ProgressBar = null;
@property(cc.Node)
ProgressBar: cc.Node = null;
@property(cc.Node)
playbar: cc.Node = null;
......@@ -39,6 +41,7 @@ export default class videoCtrl extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_START, this.touchVideoLayer, this)
this.initDrag();
}
touchVideoLayer() {
......@@ -121,9 +124,18 @@ export default class videoCtrl extends cc.Component {
let total = Math.ceil(this._videoCom.getDuration());
this.nowTime.string = this.makeTimeStr(now)
this.totalTime.string = this.makeTimeStr(total)
this.vidoSlider.progress = now / total;
this.updateSlider(now, total)
}
}
updateSlider(now, total) {
let percent = now / total
this.vidoSlider.progress = now / total;
const maxX = this.ProgressBar.width;
const minX = 0;
let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
}
makeTimeStr(time) {
let min = Math.floor(time / 60);
......@@ -132,4 +144,52 @@ export default class videoCtrl extends cc.Component {
return `${min < 10 ? "0" + min : min}:${sec < 10 ? "0" + sec : sec}`
}
@property(cc.Node) barTag: cc.Node = null;
initDrag() {
const maxX = this.vidoSlider.node.width;
const minX = 0;
this.barTag.off(cc.Node.EventType.TOUCH_START);
this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
console.log("TOUCH_START");
});
this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
const worldPos = e.getLocation();
const localPos = this.barTag.parent.convertToNodeSpaceAR(worldPos);
let newX = localPos.x;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
const percent = newX / maxX;
const dur = this._videoCom.getDuration();
let now = Math.ceil(this._videoCom?.currentTime)
let total = Math.ceil(this._videoCom.getDuration());
this.nowTime.string = this.makeTimeStr(now)
this._videoCom.currentTime = percent * dur;
});
this.barTag.off(cc.Node.EventType.TOUCH_END);
this.barTag.on(cc.Node.EventType.TOUCH_END, (e) => {
console.log("TOUCH_ENDED");
this.updateBarByPos(this.barTag.x);
});
this.barTag.off(cc.Node.EventType.MOUSE_UP);
this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
console.log("MOUSE_UP");
this.updateBarByPos(this.barTag.x);
});
}
updateBarByPos(newX) {
const maxX = this.vidoSlider.node.width;
const minX = 0;
let percent = newX / maxX;
if (percent > 1) {
percent = 1
}
const dur = this._videoCom.getDuration();
this._videoCom.currentTime = percent * dur
}
}
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