Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
duiduipeng
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
duiduipeng
Commits
59a6c521
Commit
59a6c521
authored
Apr 23, 2022
by
章红平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
a2a9bcde
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
162 additions
and
135 deletions
+162
-135
card.ts
assets/duiduipeng/newTextures/prefabs/card.ts
+2
-1
duiduipeng.fire
assets/duiduipeng/scene/duiduipeng.fire
+9
-9
duiduipeng.ts
assets/duiduipeng/scene/duiduipeng.ts
+150
-125
MyCocosSceneComponent.ts
assets/duiduipeng/script/MyCocosSceneComponent.ts
+1
-0
No files found.
assets/duiduipeng/newTextures/prefabs/card.ts
View file @
59a6c521
...
...
@@ -59,6 +59,7 @@ export default class card extends cc.Component {
playDragon
(
cb
){
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
dragon
.
node
.
active
=
true
;
this
.
dragon
.
node
.
scaleX
=
this
.
node
.
scaleX
;
this
.
dragon
.
playAnimation
(
"
newAnimation
"
,
1
)
this
.
dragon
.
on
(
dragonBones
.
EventObject
.
COMPLETE
,()
=>
{
if
(
cb
){
...
...
@@ -98,7 +99,7 @@ export default class card extends cc.Component {
.
start
();
}
else
{
cc
.
tween
(
this
.
node
)
.
to
(
0.25
,{
scaleX
:
0
})
.
to
(
0.25
,{
scaleX
:
0
.3
})
.
call
(()
=>
{
this
.
iconN
.
scaleX
=-
this
.
iconN
.
scaleX
this
.
wordLabel
.
node
.
scaleX
=
1
...
...
assets/duiduipeng/scene/duiduipeng.fire
View file @
59a6c521
...
...
@@ -916,7 +916,7 @@
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags":
0
,
"_objFlags":
512
,
"_parent": {
"__id__": 16
},
...
...
@@ -1531,7 +1531,7 @@
{
"__type__": "cc.Node",
"_name": "card",
"_objFlags":
0
,
"_objFlags":
512
,
"_parent": {
"__id__": 29
},
...
...
@@ -3870,9 +3870,9 @@
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 2
55
,
"g":
255
,
"b":
255
,
"r": 2
46
,
"g":
199
,
"b":
166
,
"a": 255
},
"_contentSize": {
...
...
@@ -5349,7 +5349,7 @@
"__id__": 2
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 125
...
...
@@ -5366,7 +5366,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
97.87
,
"width":
0
,
"height": 50.4
},
"_anchorPoint": {
...
...
@@ -5418,8 +5418,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "
Label
",
"_N$string": "
Label
",
"_string": "",
"_N$string": "",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
...
...
assets/duiduipeng/scene/duiduipeng.ts
View file @
59a6c521
...
...
@@ -16,18 +16,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
tipN
:
cc
.
Node
=
null
@
property
(
cc
.
Node
)
countDown
:
cc
.
Node
=
null
;
countDown
:
cc
.
Node
=
null
;
questionIndex
=
0
;
gameState
=
"
watching
"
watchInterval
=
null
;
gameInterval
=
null
;
watchTime
=
null
;
gameTime
=
null
;
clickNode1
:
cc
.
Node
=
null
;
clickNodeData1
=
null
canTouch
=
false
completeNum
=
0
;
gameState
=
"
watching
"
watchInterval
=
null
;
gameInterval
=
null
;
watchTime
=
null
;
gameTime
=
null
;
clickNode1
:
cc
.
Node
=
null
;
clickNodeData1
=
null
canTouch
=
false
completeNum
=
0
;
...
...
@@ -51,21 +51,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
start
():
void
{
this
.
cardParentN
.
removeAllChildren
();
cc
.
find
(
"
Canvas/uiP/bg_tip
"
).
active
=
false
;
super
.
start
();
this
.
log
(
'
initBg:
'
);
this
.
log
(
'
initBg:
'
);
this
.
initBg
();
this
.
cardParentN
.
removeAllChildren
();
// this.initData();
// cc.find("Canvas/uiP/top/timeN").active=false;
}
_cantouch
=
null
;
initData
()
{
this
.
log
(
'
initData:
'
);
this
.
log
(
'
initData:
'
);
// 所有全局变量 默认都是null
cc
.
find
(
"
Canvas/uiP/bg_tip
"
).
active
=
true
;
this
.
tittleLabel
.
string
=
this
.
data
.
title
;
this
.
tipLabel
.
string
=
this
.
data
.
questionText
;
this
.
initCards
()
// this.initTime();
}
...
...
@@ -76,47 +79,49 @@ export default class SceneComponent extends MyCocosSceneComponent {
// cc.find('Canvas/uiP/top').y=this._frameSize.height/4;
}
initCards
()
{
let
data
=
this
.
getRandomCardData
();
let
data
=
this
.
getRandomCardData
();
console
.
log
(
"
getRandomCardData==========
"
,
data
)
let
num
=
data
.
length
;
this
.
cardParentN
.
removeAllChildren
();
let
col
=
Math
.
ceil
(
num
/
2
);
let
width
=
1250
;
if
(
num
<=
8
)
width
=
1050
console
.
log
(
"
getRandomCardData==========col
"
,
col
,
num
)
if
(
num
<=
8
)
width
=
1050
if
(
col
>
2
)
{
for
(
let
i
=
0
;
i
<
num
;
i
++
)
{
let
card
=
cc
.
instantiate
(
this
.
cardP
);
this
.
cardParentN
.
addChild
(
card
)
let
indexCol
=
Math
.
floor
(
i
/
2
);
let
space
=
width
/
col
;
card
.
x
=
-
width
/
2
+
space
*
(
indexCol
+
1
/
2
);
card
.
x
=
-
width
/
2
+
space
*
(
indexCol
+
1
/
2
);
if
(
i
%
2
==
1
)
{
card
.
y
=
-
card
.
height
/
2
-
10
}
else
{
card
.
y
=
+
card
.
height
/
2
+
10
}
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
}
}
else
if
(
col
==
2
)
{
for
(
let
i
=
0
;
i
<
num
;
i
++
)
{
let
card
=
cc
.
instantiate
(
this
.
cardP
);
this
.
cardParentN
.
addChild
(
card
)
if
(
Math
.
floor
(
i
/
2
)
>
0
)
{
card
.
x
=
-
180
}
else
{
card
.
x
=
180
}
if
(
i
%
2
==
1
)
{
card
.
y
=
-
card
.
height
/
2
-
10
}
else
{
card
.
y
=
+
card
.
height
/
2
+
10
}
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
}
}
else
{
for
(
let
i
=
0
;
i
<
num
;
i
++
)
{
let
card
=
cc
.
instantiate
(
this
.
cardP
);
this
.
cardParentN
.
addChild
(
card
)
...
...
@@ -126,9 +131,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
card
.
y
=
+
card
.
height
/
2
+
10
}
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
card
.
getComponent
(
"
card
"
).
initData
(
data
[
i
],
this
)
}
}
console
.
log
(
"
this.cardParentN=====
"
,
this
.
cardParentN
)
}
getRandomCardData
()
{
let
data
=
this
.
data
.
questions
[
this
.
questionIndex
].
options
;
...
...
@@ -140,154 +146,173 @@ export default class SceneComponent extends MyCocosSceneComponent {
data
[
a
]
=
data2
;
data
[
b
]
=
data1
}
return
data
}
initTime
(){
initTime
()
{
// cc.find("Canvas/uiP/top/timeN").active=true;
let
timeN
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time
"
);
let
timeN1
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time2
"
);
this
.
watchTime
=
this
.
data
.
questions
[
0
].
watchTime
;
this
.
gameTime
=
this
.
data
.
questions
[
0
].
gameTime
;
let
numTime
=
this
.
watchTime
;
if
(
this
.
gameState
==
"
game
"
)
numTime
=
this
.
gameTime
;
timeN
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN
.
active
=
true
;
timeN1
.
active
=
false
;
let
timeN
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time
"
);
let
timeN1
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time2
"
);
this
.
watchTime
=
this
.
data
.
questions
[
0
].
watchTime
;
this
.
gameTime
=
this
.
data
.
questions
[
0
].
gameTime
;
let
numTime
=
this
.
watchTime
;
if
(
this
.
gameState
==
"
game
"
)
numTime
=
this
.
gameTime
;
timeN
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN
.
active
=
true
;
timeN1
.
active
=
false
;
}
updateTime
(){
let
timeN
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time
"
);
let
timeN1
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time2
"
);
let
numTime
=
this
.
watchTime
;
if
(
this
.
gameState
==
"
game
"
)
numTime
=
this
.
gameTime
;
timeN
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN1
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN
.
active
=
true
;
timeN1
.
active
=
false
;
if
(
numTime
<=
5
)
{
timeN
.
active
=
false
;
timeN1
.
active
=
true
;
updateTime
()
{
let
timeN
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time
"
);
let
timeN1
=
cc
.
find
(
"
Canvas/uiP/top/timeN/bg_time2
"
);
let
numTime
=
this
.
watchTime
;
if
(
this
.
gameState
==
"
game
"
)
numTime
=
this
.
gameTime
;
timeN
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN1
.
getComponentInChildren
(
cc
.
Label
).
string
=
numTime
;
timeN
.
active
=
true
;
timeN1
.
active
=
false
;
if
(
numTime
<=
5
)
{
timeN
.
active
=
false
;
timeN1
.
active
=
true
;
// if(this.gameState=="game"){
if
(
numTime
<=
1
)
{
if
(
numTime
==
1
)
this
.
playLocalAudio
(
"
time1
"
)
}
else
{
this
.
playLocalAudio
(
"
time2
"
)
}
if
(
numTime
<=
1
)
{
if
(
numTime
==
1
)
this
.
playLocalAudio
(
"
time1
"
)
}
else
{
this
.
playLocalAudio
(
"
time2
"
)
}
// }else{
if
(
this
.
gameState
==
"
watching
"
)
{
if
(
numTime
==
1
||
numTime
==
2
||
numTime
==
3
)
{
this
.
countDown
.
active
=
true
;
this
.
countDown
.
stopAllActions
();
this
.
countDown
.
scale
=
1
;
this
.
getSprforNode
(
numTime
,
this
.
countDown
);
cc
.
tween
(
this
.
countDown
)
.
to
(
0.8
,
{
scale
:
0.7
})
.
call
(()
=>
{
this
.
countDown
.
active
=
false
;
if
(
this
.
gameState
==
"
watching
"
)
{
if
(
numTime
==
1
||
numTime
==
2
||
numTime
==
3
)
{
this
.
countDown
.
active
=
true
;
this
.
countDown
.
stopAllActions
();
this
.
countDown
.
scale
=
1
;
this
.
getSprforNode
(
numTime
,
this
.
countDown
);
cc
.
tween
(
this
.
countDown
)
.
to
(
0.8
,
{
scale
:
0.7
})
.
call
(()
=>
{
this
.
countDown
.
active
=
false
;
})
.
start
()
}
}
}
// }
}
}
onStartClick
(){
this
.
tipN
.
active
=
false
;
this
.
playLocalAudio
(
"
btn
"
);
let
children
=
this
.
cardParentN
.
children
;
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getComponent
(
"
card
"
).
asyncDoFlip
(()
=>
{
if
(
i
==
children
.
length
-
1
)
this
.
startWatch
();
})
}
onStartClick
()
{
this
.
tipN
.
active
=
false
;
this
.
playLocalAudio
(
"
btn
"
);
let
children
=
this
.
cardParentN
.
children
;
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getComponent
(
"
card
"
).
asyncDoFlip
(()
=>
{
if
(
i
==
children
.
length
-
1
)
this
.
startWatch
();
})
}
}
startWatch
(){
this
.
canTouch
=
false
this
.
gameState
==
"
watching
"
startWatch
()
{
this
.
canTouch
=
false
this
.
gameState
==
"
watching
"
this
.
clearntervals
();
this
.
initTime
();
this
.
watchInterval
=
setInterval
(()
=>
{
this
.
watchInterval
=
setInterval
(()
=>
{
this
.
watchTime
--
;
console
.
log
(
"
watchtime=====
"
,
this
.
watchTime
)
if
(
this
.
watchTime
<=
0
)
{
console
.
log
(
"
watchtime=====
"
,
this
.
watchTime
)
if
(
this
.
watchTime
<=
0
)
{
this
.
clearntervals
();
let
children
=
this
.
cardParentN
.
children
;
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getComponent
(
"
card
"
).
asyncDoFlip
(()
=>
{
if
(
i
==
children
.
length
-
1
)
this
.
startGame
();
let
children
=
this
.
cardParentN
.
children
;
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getComponent
(
"
card
"
).
asyncDoFlip
(()
=>
{
if
(
i
==
children
.
length
-
1
)
this
.
startGame
();
})
}
}
}
this
.
updateTime
();
},
1000
)
},
1000
)
};
startGame
(){
this
.
canTouch
=
true
;
this
.
gameState
=
"
game
"
startGame
()
{
this
.
canTouch
=
true
;
this
.
gameState
=
"
game
"
this
.
clearntervals
();
this
.
initTime
();
this
.
gameInterval
=
setInterval
(()
=>
{
this
.
gameInterval
=
setInterval
(()
=>
{
this
.
gameTime
--
;
console
.
log
(
"
watchtime=====
"
,
this
.
gameTime
)
if
(
this
.
gameTime
<=
0
)
{
console
.
log
(
"
watchtime=====
"
,
this
.
gameTime
)
if
(
this
.
gameTime
<=
0
)
{
this
.
clearntervals
();
}
this
.
updateTime
();
},
1000
)
},
1000
)
}
clickCard
(
node
,
data
)
{
if
(
this
.
canTouch
)
{
if
(
!
this
.
clickNode1
)
{
this
.
clickNode1
=
node
;
this
.
clickNodeData1
=
data
;
clickCard
(
node
,
data
)
{
if
(
this
.
canTouch
)
{
if
(
!
this
.
clickNode1
)
{
this
.
clickNode1
=
node
;
this
.
clickNodeData1
=
data
;
this
.
clickNode1
.
getComponent
(
"
card
"
).
asyncDoFlip
()
this
.
playAudioByUrl
(
this
.
clickNodeData1
.
audio
);
}
else
{
if
(
this
.
clickNode1
==
node
)
{
this
.
playAudioByUrl
(
this
.
clickNodeData1
.
audio
);
}
else
{
if
(
this
.
clickNode1
==
node
)
{
return
;
// this.playAudioByUrl( this.clickNodeData1.audio);
}
else
{
this
.
canTouch
=
false
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
asyncDoFlip
(),
this
.
playAudioByUrl
(
data
.
audio
)])
.
then
(()
=>
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
playDragon
(),
this
.
clickNode1
.
getComponent
(
"
card
"
).
playDragon
(),
this
.
playLocalAudio
(
"
true
"
)])
.
then
(()
=>
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
doHide
(),
this
.
clickNode1
.
getComponent
(
"
card
"
).
doHide
()])
.
then
(()
=>
{
this
.
canTouch
=
true
;
this
.
clickNode1
=
null
this
.
clickNodeData1
=
null
;
this
.
completeNum
++
if
(
this
.
completeNum
==
this
.
data
.
questions
[
this
.
questionIndex
].
options
.
length
/
2
){
console
.
log
(
"
allTrue===
"
)
this
.
clearntervals
();
}
console
.
log
(
"
allActionFish=====
"
)
})
})
}
else
{
this
.
canTouch
=
false
if
(
this
.
clickNodeData1
.
pairIdx
==
data
.
pairIdx
)
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
asyncDoFlip
(),
this
.
playAudioByUrl
(
data
.
audio
)])
.
then
(()
=>
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
playDragon
(),
this
.
clickNode1
.
getComponent
(
"
card
"
).
playDragon
(),
this
.
playLocalAudio
(
"
true
"
)])
.
then
(()
=>
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
doHide
(),
this
.
clickNode1
.
getComponent
(
"
card
"
).
doHide
()])
.
then
(()
=>
{
this
.
canTouch
=
true
;
this
.
clickNode1
=
null
this
.
clickNodeData1
=
null
;
this
.
completeNum
++
if
(
this
.
completeNum
==
this
.
data
.
questions
[
this
.
questionIndex
].
options
.
length
/
2
)
{
console
.
log
(
"
allTrue===
"
)
this
.
clearntervals
();
}
console
.
log
(
"
allActionFish=====
"
)
})
})
}
)
}
else
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
asyncDoFlip
(),
this
.
playAudioByUrl
(
data
.
audio
)])
.
then
(()
=>
{
Promise
.
all
([
this
.
playLocalAudio
(
"
false
"
)])
.
then
(()
=>
{
Promise
.
all
([
node
.
getComponent
(
"
card
"
).
asyncDoFlip
(),
this
.
clickNode1
.
getComponent
(
"
card
"
).
asyncDoFlip
()])
.
then
(()
=>
{
this
.
canTouch
=
true
;
this
.
clickNode1
=
null
this
.
clickNodeData1
=
null
;
})
})
}
)
}
)
}
}
}
}
clearntervals
(){
clearntervals
()
{
// cc.find("Canvas/uiP/top/timeN").active=false;
if
(
this
.
watchInterval
)
{
if
(
this
.
watchInterval
)
{
clearInterval
(
this
.
watchInterval
);
}
if
(
this
.
gameInterval
)
{
if
(
this
.
gameInterval
)
{
clearInterval
(
this
.
gameInterval
);
}
}
...
...
assets/duiduipeng/script/MyCocosSceneComponent.ts
View file @
59a6c521
...
...
@@ -118,6 +118,7 @@ export class MyCocosSceneComponent extends cc.Component {
const
node
=
cc
.
find
(
'
Canvas/middleLayer
'
);
if
(
node
)
{
node
.
getComponent
(
cc
.
Label
).
string
=
str
;
console
.
log
(
str
);
}
else
{
console
.
log
(
str
);
}
...
...
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