Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
ns_video_map
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
ns_video_map
Commits
78d9880a
Commit
78d9880a
authored
May 09, 2022
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 加载优化
parent
1832cb60
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
246 deletions
+48
-246
ns_video_map.fire
assets/ns_video_map/scene/ns_video_map.fire
+6
-6
ns_video_map.ts
assets/ns_video_map/scene/ns_video_map.ts
+42
-240
No files found.
assets/ns_video_map/scene/ns_video_map.fire
View file @
78d9880a
...
@@ -989,15 +989,15 @@
...
@@ -989,15 +989,15 @@
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
"x":
0.5
,
"x":
1
,
"y":
0.5
"y":
1
},
},
"_trs": {
"_trs": {
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
474.06499999999994
,
579.166
,
271.898
,
315.423
,
0,
0,
0,
0,
0,
0,
...
@@ -1065,8 +1065,8 @@
...
@@ -1065,8 +1065,8 @@
"_target": null,
"_target": null,
"_alignFlags": 33,
"_alignFlags": 33,
"_left": 0,
"_left": 0,
"_right":
92.9350000000000
6,
"_right":
60.83399999999994
6,
"_top":
52.601999999999975
,
"_top":
44.577
,
"_bottom": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_horizontalCenter": 0,
...
...
assets/ns_video_map/scene/ns_video_map.ts
View file @
78d9880a
...
@@ -50,6 +50,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -50,6 +50,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
playBtn
;
playBtn
;
pauseBtn
;
pauseBtn
;
jumpBtn
;
initBtn
()
{
initBtn
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
canvas
=
cc
.
find
(
"
Canvas
"
);
...
@@ -62,6 +63,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -62,6 +63,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
this
.
data
.
isJump
!=
'
1
'
)
{
if
(
this
.
data
.
isJump
!=
'
1
'
)
{
jumpBtn
.
active
=
false
;
jumpBtn
.
active
=
false
;
}
}
this
.
jumpBtn
=
jumpBtn
;
const
playBtn
=
cc
.
find
(
'
Canvas/btn_play
'
);
const
playBtn
=
cc
.
find
(
'
Canvas/btn_play
'
);
...
@@ -118,9 +120,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -118,9 +120,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
this
.
data
.
video_url
)
{
if
(
this
.
data
.
video_url
)
{
this
.
initVideoRemote
();
this
.
initVideoRemote
();
}
}
// else {
// this.initVideoLocal();
// }
this
.
video
.
node
.
on
(
'
completed
'
,
()
=>
{
this
.
video
.
node
.
on
(
'
completed
'
,
()
=>
{
...
@@ -144,69 +143,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -144,69 +143,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
onHomeworkFinish
();
onHomeworkFinish
();
}
}
initVideoLocal
()
{
console
.
log
(
'
in initVideoLocal
'
)
const
videoLocalNode
=
cc
.
find
(
"
Canvas/videoBase/videoLocal
"
);
const
video
=
videoLocalNode
.
getComponent
(
cc
.
VideoPlayer
);
// video.isFullscreen = true;
video
.
stayOnBottom
=
true
;
// let playCount = 0;
// const playVideo = ()=> {
// playCount ++;
// if (playCount < 2) {
// return;
// }
// video.play();
// }
// videoLocalNode.on("meta-loaded", () => {
// console.log('in meta-loaded')
// playVideo();
// })
// videoLocalNode.on("ready-to-play", () => {
// console.log('in ready-to-play ');
// playVideo();
// })
// console.log("video: ", video);
// video.play();
this
.
video
=
video
;
video
.
node
.
on
(
'
ready-to-play
'
,
()
=>
{
// console.log(' in ready-to-play')
// if (this.isDestroy) {
// return;
// }
video
.
play
();
this
.
refreshBtnState
();
window
[
"
air
"
].
hideAirClassLoading
();
checkIsPlaying
();
})
const
checkIsPlaying
=
async
()
=>
{
console
.
log
(
'
bbbb 2
'
);
await
asyncDelay
(
0.1
);
if
(
video
.
currentTime
)
{
console
.
log
(
'
in aaaa
'
);
// video.pause();
}
else
{
checkIsPlaying
();
}
}
}
initVideoRemote
()
{
initVideoRemote
()
{
...
@@ -220,25 +156,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -220,25 +156,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
videoRemoteNode
.
parent
=
videoLocalNode
.
parent
;
videoRemoteNode
.
parent
=
videoLocalNode
.
parent
;
const
video
=
videoRemoteNode
.
addComponent
(
cc
.
VideoPlayer
);
const
video
=
videoRemoteNode
.
addComponent
(
cc
.
VideoPlayer
);
// let isCanPlay = false;
// const playVideo = ()=> {
// if (isCanPlay) {
// return;
// }
// isCanPlay = true;
// video.play();
// }
// videoRemoteNode.on("meta-loaded", () => {
// console.log('in meta-loaded')
// playVideo();
// })
// videoRemoteNode.on("ready-to-play", () => {
// console.log('in ready-to-play ');
// playVideo();
// })
video
.
resourceType
=
cc
.
VideoPlayer
.
ResourceType
.
REMOTE
;
video
.
resourceType
=
cc
.
VideoPlayer
.
ResourceType
.
REMOTE
;
video
.
remoteURL
=
this
.
data
.
video_url
;
video
.
remoteURL
=
this
.
data
.
video_url
;
...
@@ -251,39 +168,55 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -251,39 +168,55 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
canvas
=
cc
.
find
(
"
Canvas
"
);
video
.
node
.
on
(
'
ready-to-play
'
,
(
e
)
=>
{
video
.
node
.
on
(
'
meta-loaded
'
,
(
e
)
=>
{
console
.
log
(
'
meta-loaded e:
'
,
e
);
})
video
.
node
.
on
(
'
ready-to-play
'
,
async
(
e
)
=>
{
console
.
log
(
'
e:
'
,
e
);
console
.
log
(
'
e:
'
,
e
);
// console.log(' in ready-to-play')
// console.log(' in ready-to-play')
//
if (this.isDestroy) {
if
(
this
.
isDestroy
)
{
//
return;
return
;
//
}
}
video
.
node
.
width
=
e
.
width
;
const
width
=
e
.
nod
e
.
width
;
video
.
node
.
height
=
e
.
height
;
const
height
=
e
.
nod
e
.
height
;
const
sx
=
canvas
.
width
/
e
.
width
;
video
.
node
.
width
=
width
;
const
sy
=
canvas
.
height
/
e
.
height
;
video
.
node
.
height
=
height
;
const
sx
=
canvas
.
width
/
width
;
const
sy
=
canvas
.
height
/
height
;
video
.
node
.
scale
=
Math
.
min
(
sx
,
sy
);
video
.
node
.
scale
=
Math
.
min
(
sx
,
sy
);
console
.
log
(
'
canvas:
'
,
canvas
);
console
.
log
(
'
canvas.width:
'
,
canvas
.
width
);
console
.
log
(
'
e.node.width:
'
,
e
.
node
.
width
);
console
.
log
(
'
sx:
'
,
sx
);
console
.
log
(
'
sy:
'
,
sy
);
console
.
log
(
'
scale:
'
,
video
.
node
.
scale
);
video
.
play
();
video
.
play
();
this
.
refreshBtnState
();
this
.
refreshBtnState
();
window
[
"
air
"
].
hideAirClassLoading
();
// window["air"].hideAirClassLoading();
checkIsPlaying
();
checkIsPlaying
();
})
})
const
checkIsPlaying
=
async
()
=>
{
const
checkIsPlaying
=
()
=>
{
console
.
log
(
'
bbbb
'
);
console
.
log
(
'
bbbb
'
);
await
asyncDelay
(
0.1
);
delayCall
(
()
=>
{
if
(
video
.
currentTime
)
{
if
(
video
.
currentTime
)
{
console
.
log
(
'
in aaaa
'
);
console
.
log
(
'
in aaaa
'
);
// video.pause();
window
[
"
air
"
].
hideAirClassLoading
();
}
else
{
}
else
{
checkIsPlaying
();
checkIsPlaying
();
}
}
},
0.05
)
}
}
...
@@ -297,143 +230,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -297,143 +230,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
bgNode
.
scale
=
this
.
_mapScaleMax
;
}
pic1
=
null
;
pic2
=
null
;
initPic
()
{
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
maxW
=
canvas
.
width
*
0.7
;
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url
,
(
sprNode
)
=>
{
const
picNode1
=
sprNode
;
picNode1
.
scale
=
maxW
/
picNode1
.
width
;
picNode1
.
baseX
=
picNode1
.
x
;
canvas
.
addChild
(
picNode1
);
this
.
pic1
=
picNode1
;
const
labelNode
=
new
cc
.
Node
();
labelNode
.
color
=
cc
.
Color
.
YELLOW
;
const
label
=
labelNode
.
addComponent
(
cc
.
Label
);
label
.
string
=
this
.
data
.
text
;
label
.
fontSize
=
60
;
label
.
lineHeight
=
60
;
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
'
cc.Label
'
).
font
;
picNode1
.
addChild
(
labelNode
);
});
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url_2
,
(
sprNode
)
=>
{
const
picNode2
=
sprNode
;
picNode2
.
scale
=
maxW
/
picNode2
.
width
;
canvas
.
addChild
(
picNode2
);
picNode2
.
x
=
canvas
.
width
;
picNode2
.
baseX
=
picNode2
.
x
;
this
.
pic2
=
picNode2
;
const
labelNode
=
new
cc
.
Node
();
const
label
=
labelNode
.
addComponent
(
cc
.
RichText
);
const
size
=
60
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
cc
.
Label
).
font
;
label
.
string
=
`<outline color=#751e00 width=4><size=
${
size
}
><color=#ffffff>
${
this
.
data
.
text
}
</color></size></outline>`
label
.
lineHeight
=
size
;
picNode2
.
addChild
(
labelNode
);
});
}
initIcon
()
{
const
iconNode
=
this
.
getSprNode
(
'
icon
'
);
iconNode
.
zIndex
=
5
;
iconNode
.
anchorX
=
1
;
iconNode
.
anchorY
=
1
;
iconNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
iconNode
.
x
=
iconNode
.
parent
.
width
/
2
-
10
;
iconNode
.
y
=
iconNode
.
parent
.
height
/
2
-
10
;
iconNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
this
.
playAudioByUrl
(
this
.
data
.
audio_url
);
})
}
curPage
=
null
;
initBtn_
()
{
this
.
curPage
=
0
;
const
bottomPart
=
cc
.
find
(
'
Canvas/bottomPart
'
);
bottomPart
.
zIndex
=
5
;
// 提高层级
bottomPart
.
x
=
bottomPart
.
parent
.
width
/
2
;
bottomPart
.
y
=
-
bottomPart
.
parent
.
height
/
2
;
const
leftBtnNode
=
bottomPart
.
getChildByName
(
'
btn_left
'
);
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
return
;
}
if
(
this
.
curPage
==
0
)
{
return
;
}
this
.
curPage
=
0
this
.
leftMove
();
this
.
playLocalAudio
(
'
btn
'
);
})
const
rightBtnNode
=
bottomPart
.
getChildByName
(
'
btn_right
'
);
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
return
;
}
if
(
this
.
curPage
==
1
)
{
return
;
}
this
.
curPage
=
1
this
.
rightMove
();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish
();
this
.
playLocalAudio
(
'
btn
'
);
})
}
leftMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
}
rightMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
}
// update (dt) {},
// update (dt) {},
progressJs
=
null
progressJs
=
null
...
@@ -492,4 +288,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -492,4 +288,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
progressJs
.
setProgress
(
percent
);
this
.
progressJs
.
setProgress
(
percent
);
}
}
}
}
isDestroy
;
onDestroy
()
{
this
.
isDestroy
=
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment