Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JJ38
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
JJ38
Commits
0ac8c52e
Commit
0ac8c52e
authored
Sep 19, 2024
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
6e90e22b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
232 additions
and
23 deletions
+232
-23
JJ38.fire
assets/JJ38/scene/JJ38.fire
+4
-4
JJ38.js
assets/JJ38/scene/JJ38.js
+228
-19
No files found.
assets/JJ38/scene/JJ38.fire
View file @
0ac8c52e
...
...
@@ -1301,14 +1301,14 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0
.5
,
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
24.556
,
-147.078
,
0,
0,
0,
...
...
@@ -1370,7 +1370,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-171
,
0
,
0,
0,
0,
...
...
@@ -1464,7 +1464,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-169.952
,
0
,
0,
0,
0,
...
...
assets/JJ38/scene/JJ38.js
View file @
0ac8c52e
...
...
@@ -417,9 +417,170 @@ cc.Class({
this
.
showBackBtn
();
this
.
initListener
();
},
initListener
()
{
const
canvas
=
cc
.
find
(
'
Canvas
'
);
let
downFlag
=
false
;
const
touchStart
=
(
e
)
=>
{
this
.
canvasTouchStart
(
e
);
console
.
log
(
'
touch start
'
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
mouseDown
)
}
}
const
mouseDown
=
(
e
)
=>
{
if
(
!
downFlag
)
{
return
;
}
this
.
canvasTouchStart
(
e
);
console
.
log
(
'
mouse down
'
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
touchMove
)
// this.removeHtmlCanvasListener('touchmove');
}
}
const
touchMove
=
(
e
)
=>
{
this
.
canvasTouchMove
(
e
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
,
mouseMove
)
}
}
const
mouseMove
=
(
e
)
=>
{
if
(
!
downFlag
)
{
return
;
}
this
.
canvasTouchMove
(
e
);
console
.
log
(
'
mouse move
'
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
touchMove
)
// this.removeHtmlCanvasListener('touchmove');
}
}
const
touchEnd
=
(
e
)
=>
{
downFlag
=
false
;
this
.
canvasTouchEnd
(
e
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_UP
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
mouseUp
)
}
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_LEAVE
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
MOUSE_LEAVE
,
mouseUp
)
}
// this.removeHtmlTouchEnd();
}
const
mouseUp
=
(
e
)
=>
{
downFlag
=
false
;
this
.
canvasTouchEnd
(
e
);
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_END
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
touchEnd
)
}
if
(
canvas
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
))
{
canvas
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
touchEnd
)
}
}
canvas
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
touchStart
)
canvas
.
on
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
mouseDown
)
canvas
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
touchMove
)
canvas
.
on
(
cc
.
Node
.
EventType
.
MOUSE_MOVE
,
mouseMove
)
canvas
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
touchEnd
)
canvas
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
touchEnd
)
canvas
.
on
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
mouseUp
)
},
canvasTouchStart
(
e
)
{
const
pos
=
e
.
getLocation
();
// this.knife.x = pos.x - e.currentTarget.width / 2;
// this.knife.y = pos.y - e.currentTarget.height / 2;
},
canvasTouchMove
(
e
)
{
const
pos
=
e
.
getLocation
();
// this.knife.x = pos.x - e.currentTarget.width / 2;
// this.knife.y = pos.y - e.currentTarget.height / 2;
if
(
!
this
.
isProgressBtnDown
)
{
return
;
}
const
curTouchBar
=
this
.
progressBtn
;
if
(
curTouchBar
)
{
const
px
=
pos
.
x
-
e
.
currentTarget
.
width
/
2
;
const
py
=
pos
.
y
-
e
.
currentTarget
.
height
/
2
;
const
worldPos
=
this
.
canvas
.
convertToWorldSpaceAR
(
cc
.
v2
(
px
,
py
));
const
localPos
=
curTouchBar
.
parent
.
convertToNodeSpaceAR
(
worldPos
);
curTouchBar
.
x
=
localPos
.
x
;
if
(
curTouchBar
.
x
<
curTouchBar
.
minX
)
{
curTouchBar
.
x
=
curTouchBar
.
minX
;
}
else
if
(
curTouchBar
.
x
>
curTouchBar
.
maxX
)
{
curTouchBar
.
x
=
curTouchBar
.
maxX
;
}
this
.
setPlayerTimeByTouchBar
(
curTouchBar
);
}
},
setPlayerTimeByTouchBar
(
curTouchBar
)
{
let
percent
=
curTouchBar
.
x
/
curTouchBar
.
maxX
;
const
duration
=
this
.
totalTime
;
// this.muteVideoPlayer.getDuration();
const
curTime
=
duration
*
percent
;
// this.muteVideoPlayer.currentTime = curTime;
// console.log("duration: " , duration);
// console.log("curTouchBar: " , curTouchBar);
// console.log("curTime: " , curTime);
cc
.
audioEngine
.
setCurrentTime
(
this
.
audioId
,
curTime
);
this
.
setProgressBar
(
curTime
);
// console.log('this.audioId: ', this.audioId);
},
canvasTouchEnd
(
e
)
{
this
.
isProgressBtnDown
=
false
;
// if (!this._curShowItem) {
// return;
// }
// this._curShowItem = null;
},
initBgContainer
()
{
const
bgContainer
=
cc
.
find
(
'
Canvas/bg_container
'
);
const
canvas
=
cc
.
find
(
"
Canvas
"
);
...
...
@@ -457,6 +618,9 @@ cc.Class({
const
playBtn
=
cc
.
find
(
'
play
'
,
audioPlayer
);
const
pauseBtn
=
cc
.
find
(
'
pause
'
,
audioPlayer
);
this
.
playBtn
=
playBtn
;
this
.
pauseBtn
=
pauseBtn
;
if
(
!
this
.
data
.
audio_url
)
{
return
;
}
...
...
@@ -467,7 +631,22 @@ cc.Class({
this
.
progressBtn
=
cc
.
find
(
"
timeBar/progressBtn
"
,
audioPlayer
);
this
.
progressBtn
.
baseX
=
this
.
progressBtn
.
x
;
this
.
progressBtn
.
on
(
'
touchstart
'
,
(
e
)
=>
{});
this
.
progressBtn
.
minX
=
0
;
this
.
progressBtn
.
maxX
=
this
.
progressBtn
.
parent
.
width
;
this
.
progressBtn
.
on
(
'
touchstart
'
,
(
e
)
=>
{
this
.
isProgressBtnDown
=
true
;
if
(
this
.
audioId
!=
null
)
{
this
.
pauseAudio
();
// cc.audioEngine.pause(this.audioId);
}
});
let
audioClip
;
...
...
@@ -479,7 +658,12 @@ cc.Class({
if
(
!
this
.
totalTime
)
{
totalTimeAudioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0
);
this
.
audioId
=
totalTimeAudioId
;
checkHasDuration
();
}
else
{
this
.
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
cc
.
audioEngine
.
pause
(
this
.
audioId
);
}
...
...
@@ -528,44 +712,52 @@ cc.Class({
// this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
// cc.audioEngine.pause(this.audioId);
// this.audioId = audioId;
let
audioId
;
playBtn
.
on
(
'
touchstart
'
,
()
=>
{
pauseBtn
.
active
=
true
;
playBtn
.
active
=
false
;
this
.
isAudioPlaying
=
true
;
if
(
audioId
)
{
cc
.
audioEngine
.
resume
(
audioId
);
if
(
this
.
audioId
!=
null
)
{
cc
.
audioEngine
.
resume
(
this
.
audioId
);
}
else
{
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
}
this
.
audioId
=
audioId
;
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
cc
.
audioEngine
.
setFinishCallback
(
this
.
audioId
,
()
=>
{
if
(
this
.
isDestroy
)
{
return
;
}
this
.
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
cc
.
audioEngine
.
pause
(
this
.
audioId
);
playBtn
.
active
=
true
;
pauseBtn
.
active
=
false
;
this
.
isAudioPlaying
=
false
;
this
.
audioId
=
audioId
=
null
;
//
this.audioId = audioId = null;
});
})
pauseBtn
.
on
(
'
touchstart
'
,
()
=>
{
playBtn
.
active
=
true
;
pauseBtn
.
active
=
false
;
this
.
pauseAudio
()
;
})
cc
.
audioEngine
.
pause
(
audioId
);
},
this
.
isAudioPlaying
=
false
;
})
pauseAudio
()
{
this
.
playBtn
.
active
=
true
;
this
.
pauseBtn
.
active
=
false
;
cc
.
audioEngine
.
pause
(
this
.
audioId
);
this
.
isAudioPlaying
=
false
;
},
initPanel
()
{
...
...
@@ -696,6 +888,21 @@ cc.Class({
return
arr
;
},
setProgressBar
(
curTime
=
null
)
{
if
(
this
.
audioId
==
null
)
{
return
;
}
if
(
!
curTime
)
{
curTime
=
cc
.
audioEngine
.
getCurrentTime
(
this
.
audioId
);
}
this
.
curTimeLabel
.
string
=
this
.
formatTime
(
curTime
*
1000
);
// console.log('this.totalTime: ' , this.totalTime);
this
.
progressBar
.
progress
=
curTime
/
this
.
totalTime
;
this
.
progressBtn
.
x
=
this
.
progressBtn
.
baseX
+
this
.
progressBtn
.
parent
.
width
*
this
.
progressBar
.
progress
;
},
updateTimeBar
()
{
if
(
!
this
.
isAudioPlaying
)
{
...
...
@@ -707,11 +914,13 @@ cc.Class({
return
;
}
const
curTime
=
cc
.
audioEngine
.
getCurrentTime
(
this
.
audioId
);
this
.
curTimeLabel
.
string
=
this
.
formatTime
(
curTime
*
1000
);
this
.
setProgressBar
();
this
.
progressBar
.
progress
=
curTime
/
this
.
totalTime
;
this
.
progressBtn
.
x
=
this
.
progressBtn
.
baseX
+
this
.
progressBtn
.
parent
.
width
*
this
.
progressBar
.
progress
;
// const curTime = cc.audioEngine.getCurrentTime(this.audioId);
// this.curTimeLabel.string = this.formatTime(curTime * 1000);
// this.progressBar.progress = curTime / this.totalTime;
// this.progressBtn.x = this.progressBtn.baseX + this.progressBtn.parent.width * this.progressBar.progress;
},
update
()
{
...
...
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