Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Sbox_FT_08
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
Sbox_FT_08
Commits
93ac964c
Commit
93ac964c
authored
Dec 02, 2020
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fix
parent
560a773f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
26 deletions
+43
-26
Cartoon.js
play/assets/tmpGame/script/Cartoon.js
+11
-4
GameLogic.js
play/assets/tmpGame/script/GameLogic.js
+30
-20
Scene.js
play/assets/tmpGame/script/Scene.js
+2
-2
No files found.
play/assets/tmpGame/script/Cartoon.js
View file @
93ac964c
...
...
@@ -16,6 +16,7 @@ export default class Cartoon {
}
audios
=
{}
audioIDs
=
{}
initCartoonElement
(
key
,
node
)
{
if
(
!
node
)
{
...
...
@@ -174,6 +175,7 @@ export default class Cartoon {
cb
();
});
}
this
.
audioIDs
[
audio_url
]
=
audioId
resolve
(
audioId
)
});
}
else
{
...
...
@@ -186,6 +188,7 @@ export default class Cartoon {
cb
();
});
}
this
.
audioIDs
[
audio_url
]
=
audioId
resolve
(
audioId
)
}
}
...
...
@@ -193,13 +196,17 @@ export default class Cartoon {
}
stopAllAudio
(
exceptUrls
=
[])
{
for
(
let
key
in
this
.
audio
Callback
)
{
for
(
let
key
in
this
.
audio
IDs
)
{
if
(
exceptUrls
.
indexOf
(
key
)
==
-
1
)
{
this
.
audioCallback
[
key
]()
if
(
this
.
audioCallback
[
key
])
{
this
.
audioCallback
[
key
]()
}
if
(
this
.
audioIDs
[
key
])
{
cc
.
audioEngine
.
stop
(
this
.
audioIDs
[
key
])
delete
this
.
audioIDs
[
key
];
}
}
}
this
.
audioCallback
=
{}
cc
.
audioEngine
.
stopAll
()
}
// Tweenchange
...
...
play/assets/tmpGame/script/GameLogic.js
View file @
93ac964c
...
...
@@ -55,7 +55,7 @@ export default class GameLogic {
}
})
this
.
initBg
()
this
.
initNodes
();
this
.
resetPosition
();
...
...
@@ -63,7 +63,7 @@ export default class GameLogic {
this
.
initBirds
();
this
.
initImageCards
();
this
.
initTitle
();
this
.
snowing
(
5000
)
this
.
initMaskLayer
();
}
...
...
@@ -125,6 +125,9 @@ export default class GameLogic {
bgNode
.
scale
=
this
.
g_systemOption
.
mapScaleMax
;
bgSnowContainer
.
scale
=
this
.
g_systemOption
.
mapScaleMax
;
bgNodeSnow
.
width
=
cc
.
winSize
.
width
bgSnowContainer
.
height
=
cc
.
winSize
.
height
bgSnowContainer
.
width
=
cc
.
winSize
.
width
tree1
.
height
=
cc
.
winSize
.
height
tree2
.
height
=
cc
.
winSize
.
height
tree3
.
height
=
cc
.
winSize
.
height
...
...
@@ -229,6 +232,7 @@ export default class GameLogic {
}
this
.
disableClick
(
`card_
${
index
+
1
}
_image_container`
)
let
birdStandCard
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
this
.
m_currentQuestionArray
[
this
.
m_currentQuestion
]
+
1
}
_image_container`
)
if
(
this
.
m_currentQuestion
==
imageContainer
.
correctIndex
)
{
this
.
g_cartoon
.
playAudio
(
"
good_job
"
,
()
=>
{
this
.
g_cartoon
.
playAudio
(
this
.
g_formData
.
dataArray
[
this
.
m_currentQuestion
].
audio_url
)
...
...
@@ -255,14 +259,18 @@ export default class GameLogic {
})
})
}
else
{
this
.
g_cartoon
.
getCartoonElement
(
"
bird_1
"
).
wrong
()
this
.
g_cartoon
.
getCartoonElement
(
"
bird_2
"
).
wrong
()
this
.
g_cartoon
.
playAudio
(
"
try_again
"
,
()
=>
{
setTimeout
(()
=>
{
this
.
g_cartoon
.
playAudio
(
this
.
g_formData
.
dataArray
[
this
.
m_currentQuestion
].
audio_url
)
this
.
enableClick
(
`card_
${
index
+
1
}
_image_container`
)
},
1000
)
})
if
(
birdStandCard
.
cardIndex
!=
index
)
{
this
.
g_cartoon
.
getCartoonElement
(
"
bird_1
"
).
wrong
()
this
.
g_cartoon
.
getCartoonElement
(
"
bird_2
"
).
wrong
()
this
.
g_cartoon
.
playAudio
(
"
try_again
"
,
()
=>
{
setTimeout
(()
=>
{
this
.
g_cartoon
.
playAudio
(
this
.
g_formData
.
dataArray
[
this
.
m_currentQuestion
].
audio_url
)
this
.
enableClick
(
`card_
${
index
+
1
}
_image_container`
)
},
1000
)
})
}
else
{
this
.
enableClick
(
`card_
${
index
+
1
}
_image_container`
)
}
}
})
...
...
@@ -484,7 +492,7 @@ export default class GameLogic {
endGame
()
{
this
.
m_gameEnd
=
true
;
this
.
snowing
(
5000
)
// let resetBtn = this.g_cartoon.getCartoonElement("restart_button")
// resetBtn.node.active = true;
}
...
...
@@ -507,9 +515,8 @@ export default class GameLogic {
for
(
let
index
=
0
;
index
<
10
;
index
++
)
{
const
card
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
`
)
}
this
.
g_cartoon
.
stopAllAudio
()
this
.
g_cartoon
.
stopAllAudio
(
[
this
.
g_formData
.
bgMusic
?
this
.
g_formData
.
bgMusic
:
""
]
)
this
.
showMaskLayer
(()
=>
{
this
.
initBGMusic
()
this
.
resetPosition
();
this
.
initImageCards
();
this
.
initTitle
();
...
...
@@ -736,6 +743,8 @@ export default class GameLogic {
snowing
(
time
=
5000
)
{
const
parent
=
this
.
g_cartoon
.
getCartoonElement
(
"
snow_container
"
)
const
downHeigth
=
parent
.
node
.
height
/
2
+
50
console
.
log
(
downHeigth
,
this
.
g_systemOption
.
mapScaleMax
)
const
getSnow
=
(
index
)
=>
{
const
snowArray
=
[
this
.
getSprNode
(
'
snow_1
'
),
this
.
getSprNode
(
'
snow_2
'
),
this
.
getSprNode
(
'
snow_3
'
),
this
.
getSprNode
(
'
snow_4
'
)
...
...
@@ -743,23 +752,24 @@ export default class GameLogic {
const
sf
=
this
.
getSprNode
(
`snow_
${
index
}
`
).
getComponent
(
cc
.
Sprite
).
spriteFrame
;
const
node
=
new
cc
.
Node
();
node
.
addComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
node
.
y
=
cc
.
winSize
.
height
/
2
+
node
.
height
-
10
;
node
.
y
=
downHeigth
node
.
x
=
Math
.
ceil
(
Math
.
random
()
*
cc
.
winSize
.
width
)
-
cc
.
winSize
.
width
/
2
node
.
parent
=
parent
.
node
return
node
;
}
const
downTime
=
Math
.
ceil
((
cc
.
winSize
.
height
/
100
)
*
1000
)
/
1000
console
.
log
(
downTime
)
let
intervalID
=
setInterval
(()
=>
{
let
snow
=
getSnow
(
Math
.
ceil
(
Math
.
random
()
*
4
)
)
this
.
g_cartoon
.
tweenChange
(
snow
,
{
y
:
-
cc
.
winSize
.
height
/
2
},
2000
)
cc
.
tween
(
snow
).
to
(
3
,
{
y
:
-
cc
.
winSize
.
height
/
2
}).
call
(()
=>
snow
.
destroy
()).
start
()
// this.g_cartoon.tweenChange(snow, {y: -cc.winSize.height / 2}, downTime
)
cc
.
tween
(
snow
).
to
(
downTime
,
{
y
:
-
cc
.
winSize
.
height
/
2
}).
call
(()
=>
snow
.
destroy
()).
start
()
},
100
);
setTimeout
(()
=>
{
clearInterval
(
intervalID
)
},
time
);
//
setTimeout(() => {
//
clearInterval(intervalID)
//
}, time);
}
...
...
play/assets/tmpGame/script/Scene.js
View file @
93ac964c
...
...
@@ -93,8 +93,8 @@ cc.Class({
getDefaultData
()
{
// const dataJson = '{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"","titleText":"TEstd","questionAudio_url":"","dataArray":[{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/06cc843598a912921f6ca3acfde6220b.png","audio_url":"http://staging-teach.cdn.ireadabc.com/3b5540cc95a006dff8c41dba7537075a.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/571974922f6678111348a5643dba7e20.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/78579114773af12a7aec6723e3b9d475.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/c99e82e1c3f087c6dc0469e30c624f70.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/5b45c89ac9e899d76522767219b1346b.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/2e28eae8f0e0f01193da6f3677379ed3.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/fad2dac4f8b59a185dc30d42617c2ca8.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/6c3fca11052464102407f173e4a83db9.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/ec82c796af801486548ae98623f614d2.png"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/ac4b9422df1556f80ac5c3058cd3d670.png"}]}}'
// const dataJson = '{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"http://staging-teach.cdn.ireadabc.com/ad58bae62ea02cf215ce7dee22df306f.mp3","titleText":"TEstd","questionAudio_url":"http://staging-teach.cdn.ireadabc.com/2bf96923b83ee0c5f20930386ce07384.mp3","dataArray":[{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/06cc843598a912921f6ca3acfde6220b.png","audio_url":"http://staging-teach.cdn.ireadabc.com/3b5540cc95a006dff8c41dba7537075a.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/571974922f6678111348a5643dba7e20.png","audio_url":"http://staging-teach.cdn.ireadabc.com/ae7c0930a45d0ffc9f13182298e2be71.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/78579114773af12a7aec6723e3b9d475.png","audio_url":"http://staging-teach.cdn.ireadabc.com/c14938125a52096dc0be9fbbf6638cb2.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/c99e82e1c3f087c6dc0469e30c624f70.png","audio_url":"http://staging-teach.cdn.ireadabc.com/135c628899396df62c14567f46d61f3f.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/5b45c89ac9e899d76522767219b1346b.png","audio_url":"http://staging-teach.cdn.ireadabc.com/3b5540cc95a006dff8c41dba7537075a.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/2e28eae8f0e0f01193da6f3677379ed3.png","audio_url":"http://staging-teach.cdn.ireadabc.com/cb0ac1d1bcdfdaf768f0a06d3fff37a3.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/fad2dac4f8b59a185dc30d42617c2ca8.png","audio_url":"http://staging-teach.cdn.ireadabc.com/9df3f14bc88bcffc49b6717c40428ed8.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/6c3fca11052464102407f173e4a83db9.png","audio_url":"http://staging-teach.cdn.ireadabc.com/d5a5ac2f45431a8a15492cb9f78e0396.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/ec82c796af801486548ae98623f614d2.png","audio_url":"http://staging-teach.cdn.ireadabc.com/fb08783926362bf64232e2ec6966011d.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/ac4b9422df1556f80ac5c3058cd3d670.png","audio_url":"http://staging-teach.cdn.ireadabc.com/fb08783926362bf64232e2ec6966011d.mp3"}]}}'
const
dataJson
=
'
{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"http://staging-teach.cdn.ireadabc.com/ad58bae62ea02cf215ce7dee22df306f
.mp3","titleText":"TEstd","questionAudio_url":"http://staging-teach.cdn.ireadabc.com/2bf96923b83ee0c5f20930386ce07384.mp3","dataArray":[{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/06cc843598a912921f6ca3acfde6220b.png","audio_url":"http://staging-teach.cdn.ireadabc.com/3b5540cc95a006dff8c41dba7537075a.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/571974922f6678111348a5643dba7e20.png","audio_url":"http://staging-teach.cdn.ireadabc.com/ae7c0930a45d0ffc9f13182298e2be71.mp3"}]}}
'
//
const dataJson = '{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"","titleText":"","questionAudio_url":"","dataArray":[]}}'
// const dataJson = '{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"http://staging-teach.cdn.ireadabc.com/2bf96923b83ee0c5f20930386ce07384
.mp3","titleText":"TEstd","questionAudio_url":"http://staging-teach.cdn.ireadabc.com/2bf96923b83ee0c5f20930386ce07384.mp3","dataArray":[{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/06cc843598a912921f6ca3acfde6220b.png","audio_url":"http://staging-teach.cdn.ireadabc.com/3b5540cc95a006dff8c41dba7537075a.mp3"},{"text":"","image_url":"http://staging-teach.cdn.ireadabc.com/571974922f6678111348a5643dba7e20.png","audio_url":"http://staging-teach.cdn.ireadabc.com/ae7c0930a45d0ffc9f13182298e2be71.mp3"}]}}'
const
dataJson
=
'
{"contentObj":{"version":"1.0","key":"DataKey_Sbox_FT_08","bgMusic":"","titleText":"","questionAudio_url":"","dataArray":[]}}
'
const
data
=
JSON
.
parse
(
dataJson
);
return
data
;
},
...
...
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