Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dfzx_cocos_dqq
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
dfzx_cocos_dqq
Commits
32067dad
Commit
32067dad
authored
Mar 22, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 加音效
parent
93a5aa83
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
476 additions
and
253 deletions
+476
-253
dfzx_cocos_dqq.fire
play/assets/dfzx_cocos_dqq/scene/dfzx_cocos_dqq.fire
+436
-243
dfzx_cocos_dqq.js
play/assets/dfzx_cocos_dqq/scene/dfzx_cocos_dqq.js
+36
-9
util.js
play/assets/dfzx_cocos_dqq/script/util.js
+4
-1
No files found.
play/assets/dfzx_cocos_dqq/scene/dfzx_cocos_dqq.fire
View file @
32067dad
This diff is collapsed.
Click to expand it.
play/assets/dfzx_cocos_dqq/scene/dfzx_cocos_dqq.js
View file @
32067dad
...
...
@@ -153,17 +153,17 @@ cc.Class({
await
asyncTweenTo
(
BtnStart
,
0.1
,
{
opacity
:
0
});
BtnStart
.
active
=
false
;
this
.
gameStart
();
});
}
,
this
.
playAudio
.
bind
(
this
,
'
btn
'
)
);
const
BtnRestart
=
cc
.
find
(
'
Canvas/bg/BtnRestart
'
);
addBtnListener
(
BtnRestart
,
async
()
=>
{
await
asyncTweenTo
(
BtnRestart
,
0.1
,
{
opacity
:
0
});
BtnRestart
.
active
=
false
;
this
.
gameStart
();
});
}
,
this
.
playAudio
.
bind
(
this
,
'
btn
'
)
);
const
BtnSpeaker
=
cc
.
find
(
'
Canvas/bg/BtnSpeaker
'
);
addBtnListener
(
BtnSpeaker
,
async
()
=>
{
await
this
.
playQuestionAudio
();
});
}
,
this
.
playAudio
.
bind
(
this
,
'
btn
'
)
);
const
bg
=
cc
.
find
(
'
Canvas/bg
'
);
bg
.
on
(
'
touchstart
'
,
(
event
)
=>
{
...
...
@@ -217,6 +217,8 @@ cc.Class({
star
.
x
=
startPos
.
x
;
star
.
y
=
startPos
.
y
-
starBig
.
height
;
this
.
playAudio
(
'
star
'
);
cc
.
tween
(
star
)
.
to
(
0.3
,
{
y
:
middlePos
.
y
+
80
},
{
easing
:
'
quadOut
'
})
.
to
(
0.1
,
{
y
:
middlePos
.
y
+
40
,
scaleX
:
1.2
/
starBase
.
scale
,
scaleY
:
0.8
/
starBase
.
scale
},
{
easing
:
'
quadOut
'
})
...
...
@@ -244,10 +246,12 @@ cc.Class({
onGameEnd
()
{
showTrebleFirework
(
cc
.
find
(
'
Canvas/bg
'
),
cc
.
find
(
'
RabbonBase
'
).
children
);
this
.
playAudio
(
'
end
'
);
onHomeworkFinish
();
this
.
hideGuns
();
const
BtnRestart
=
cc
.
find
(
'
Canvas/bg/BtnRestart
'
);
BtnRestart
.
active
=
true
;
BtnRestart
.
opacity
=
255
;
},
async
gameStart
()
{
...
...
@@ -264,9 +268,17 @@ cc.Class({
showGuns
()
{
const
bg
=
cc
.
find
(
'
Canvas/bg
'
);
const
gunBase
=
cc
.
find
(
'
Canvas/bg/GunBase
'
);
this
.
playAudio
(
'
move
'
);
asyncTweenTo
(
gunBase
,
0.5
,
{
y
:
-
bg
.
height
/
2
});
},
hideGuns
()
{
const
bg
=
cc
.
find
(
'
Canvas/bg
'
);
const
gunBase
=
cc
.
find
(
'
Canvas/bg/GunBase
'
);
this
.
playAudio
(
'
move
'
);
asyncTweenTo
(
gunBase
,
0.5
,
{
y
:
-
bg
.
height
/
2
-
gunBase
.
height
});
},
showBallsinterval
:
null
,
startShowBalls
()
{
const
currentQuestion
=
this
.
data
.
questionList
[
this
.
_status
.
currentQuestionIdx
];
...
...
@@ -316,6 +328,8 @@ cc.Class({
.
repeatForever
()
.
start
();
this
.
playAudio
(
'
appare
'
);
ball
.
on
(
'
touchstart
'
,
async
(
event
)
=>
{
if
(
ball
.
canNotTouch
)
{
return
;
...
...
@@ -393,9 +407,11 @@ cc.Class({
if
(
!
currentQuestion
)
{
return
;
}
this
.
speakerBlink
();
await
playAudioByUrlSync
(
currentQuestion
.
questionAudio
);
this
.
speakerStopBlink
();
this
.
playAudio
(
'
question
'
,
async
()
=>
{
this
.
speakerBlink
();
await
playAudioByUrlSync
(
currentQuestion
.
questionAudio
);
this
.
speakerStopBlink
();
});
},
speakerList
:
null
,
...
...
@@ -414,6 +430,7 @@ cc.Class({
async
shootTarget
(
node
,
location
,
shootBullet
)
{
const
GunPos
=
cc
.
find
(
'
Canvas/bg/GunBase/GunPos
'
);
const
Gun
=
cc
.
find
(
'
Canvas/bg/GunBase/Gun
'
);
const
Water
=
cc
.
find
(
'
Canvas/bg/GunBase/Gun/Water
'
);
const
Muzzle
=
cc
.
find
(
'
Canvas/bg/GunBase/Gun/Muzzle
'
);
const
bg
=
cc
.
find
(
'
Canvas/bg
'
)
let
offsetY
=
0
;
...
...
@@ -432,6 +449,7 @@ cc.Class({
const
angle
=
cc
.
v2
(
0
,
1
).
signAngle
(
shootSide
)
*
180
/
Math
.
PI
;
bullet
.
angle
=
angle
;
asyncTweenTo
(
Water
,
0.1
,
{
angle
:
-
angle
});
await
asyncTweenTo
(
Gun
,
0.1
,
{
angle
:
angle
,
scaleY
:
0.95
});
let
startPos
=
exchangeNodePos
(
bg
,
Muzzle
);
bullet
.
x
=
startPos
.
x
;
...
...
@@ -442,6 +460,8 @@ cc.Class({
.
to
(
0.1
,
{
scaleX
:
1
,
scaleY
:
1
})
.
start
();
this
.
playAudio
(
'
light
'
);
let
targetPos
=
bg
.
convertToNodeSpaceAR
(
cc
.
v2
(
location
.
x
,
location
.
y
+
offsetY
));
let
flySide
=
cc
.
v2
(
targetPos
.
x
-
startPos
.
x
,
targetPos
.
y
-
startPos
.
y
);
await
asyncTweenTo
(
bullet
,
0.1
,
{
...
...
@@ -457,6 +477,7 @@ cc.Class({
},
async
targetDistroy
(
node
)
{
this
.
playAudio
(
'
right
'
);
const
bg
=
node
.
getChildByName
(
'
bg
'
);
bg
.
active
=
false
;
const
DistroyAnime
=
node
.
getChildByName
(
'
DistroyAnime
'
);
...
...
@@ -468,6 +489,7 @@ cc.Class({
},
async
targetLaugh
(
node
)
{
this
.
playAudio
(
'
wrong
'
);
const
x
=
node
.
x
;
let
offsetX
=
RandomInt
(
20
,
50
)
*
2
*
(
RandomInt
(
2
)
-
0.5
);
let
offsetY
=
RandomInt
(
20
,
50
)
*
2
*
(
RandomInt
(
2
)
-
0.5
);
...
...
@@ -478,9 +500,14 @@ cc.Class({
await
asyncTweenTo
(
node
,
0.05
,
{
x
:
x
});
},
async
playAudio
(
audioName
)
{
playAudio
(
audioName
,
cb
)
{
const
audioNode
=
cc
.
find
(
`AudioBase/
${
audioName
}
`
);
const
audioClip
=
audioNode
.
getComponent
(
cc
.
AudioSource
).
clip
;
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
const
id
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
cc
.
audioEngine
.
setFinishCallback
(
id
,
()
=>
{
if
(
cb
)
{
cb
();
}
});
}
});
play/assets/dfzx_cocos_dqq/script/util.js
View file @
32067dad
...
...
@@ -409,7 +409,7 @@ export async function jelly(node, offset = 0.1) {
});
}
export
function
addBtnListener
(
node
,
cb
)
{
export
function
addBtnListener
(
node
,
cb
,
beforeJelly
=
null
)
{
const
button
=
node
.
getComponent
(
cc
.
Button
);
if
(
!
button
)
{
node
.
addComponent
(
cc
.
Button
);
...
...
@@ -419,6 +419,9 @@ export function addBtnListener(node, cb) {
return
;
}
node
.
canNotClick
=
true
;
if
(
beforeJelly
)
{
beforeJelly
();
}
await
jelly
(
node
);
await
cb
();
node
.
canNotClick
=
false
;
...
...
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