Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sn14_dds
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
sn14_dds
Commits
317d574e
Commit
317d574e
authored
Sep 18, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础玩法完成
parent
56ad57dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2726 additions
and
2613 deletions
+2726
-2613
sn05_night.fire
assets/sn05_night/scene/sn05_night.fire
+2543
-2501
sn05_night.ts
assets/sn05_night/scene/sn05_night.ts
+183
-112
No files found.
assets/sn05_night/scene/sn05_night.fire
View file @
317d574e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
assets/sn05_night/scene/sn05_night.ts
View file @
317d574e
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util_sn05_night
"
;
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util_sn05_night
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent_sn05_night
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent_sn05_night
"
;
import
pg
from
"
./pg_sn05_night
"
;
import
pg
from
"
./pg_sn05_night
"
;
import
ImgVoice
from
"
./ImgVoice
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -55,11 +56,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -55,11 +56,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
initView
()
{
}
initView
()
{
}
initEvent
()
{
initEvent
()
{
pg
.
view
.
touchOn
(
this
.
btn_laba
,
this
.
onTouchAudio
,
this
);
}
}
resetView
()
{
};
resetView
()
{
};
initGame
()
{
initGame
()
{
pg
.
audio
.
playLocalBgm
(
pg
.
view
.
find
(
this
,
"
res/audio/fly
"
))
//
pg.audio.playLocalBgm(pg.view.find(this, "res/audio/fly"))
this
.
nextQuestion
();
this
.
nextQuestion
();
}
}
replay
()
{
replay
()
{
...
@@ -98,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -98,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
rightList
:
Array
<
any
>
;
private
rightList
:
Array
<
any
>
;
private
startCreate
:
boolean
;
private
startCreate
:
boolean
;
private
lastTime
:
number
;
private
lastTime
:
number
;
private
dataList
:
Array
<
any
>
;
nextQuestion
()
{
nextQuestion
()
{
if
(
this
.
loopId
)
cc
.
audioEngine
.
stopEffect
(
this
.
loopId
);
if
(
this
.
loopId
)
cc
.
audioEngine
.
stopEffect
(
this
.
loopId
);
this
.
loopId
=
null
;
this
.
loopId
=
null
;
...
@@ -108,30 +111,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -108,30 +111,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
//TODO: 需要增加总倒计时
//TODO: 需要增加总倒计时
this
.
totalTime
=
Number
(
this
.
currentQuestion
.
duration
)
||
10
;
//异常只给10秒duration
this
.
time
=
this
.
totalTime
this
.
currentQuestion
.
options
=
this
.
currentQuestion
.
options
.
map
((
op
,
i
)
=>
{
this
.
currentQuestion
.
options
=
this
.
currentQuestion
.
options
.
map
((
op
,
i
)
=>
{
op
.
id
=
i
;
op
.
id
=
i
;
return
op
;
return
op
;
})
})
this
.
dataList
=
this
.
currentQuestion
.
options
.
concat
();
this
.
itemList
=
this
.
freeArea
.
concat
();
this
.
lastTime
=
new
Date
().
getTime
();
this
.
lastTime
=
new
Date
().
getTime
();
this
.
rightList
=
[];
this
.
rightList
=
[];
this
.
onTouchAudio
().
then
(()
=>
{
pg
.
view
.
find
(
this
,
'
layer_game/layer_paopao
'
).
removeAllChildren
();
this
.
startQuestion
();
this
.
startQuestion
();
})
this
.
playAudioUrl
();
this
.
scheduleOnce
(()
=>
{
this
.
startCreate
=
true
;
},
0.5
)
}
}
playAudioUrl
()
{
@
property
(
cc
.
Node
)
btn_laba
:
cc
.
Node
=
null
;
onTouchAudio
()
{
return
new
Promise
(
res
=>
{
return
new
Promise
(
res
=>
{
this
.
btn_laba
.
getComponent
(
ImgVoice
).
playVoiceStart
();
pg
.
audio
.
playAudioByUrl
(
this
.
currentQuestion
.
questionAudio
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
currentQuestion
.
questionAudio
).
then
(()
=>
{
this
.
scheduleOnce
(()
=>
{
this
.
btn_laba
.
getComponent
(
ImgVoice
).
playVoiceEnd
();
this
.
playAudioUrl
();
res
(
''
);
},
2
)
})
})
})
})
}
}
...
@@ -139,33 +140,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -139,33 +140,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 制造气泡
// 制造气泡
private
canTouch
:
boolean
;
private
canTouch
:
boolean
;
startQuestion
()
{
startQuestion
()
{
let
layer_paopao
=
pg
.
view
.
find
(
this
,
'
layer_game/layer_paopao
'
)
this
.
startCreate
=
true
;
let
paoaoParent
=
pg
.
view
.
find
(
this
,
'
layer_game/paopao
'
)
this
.
time
=
1
;
let
list
=
this
.
currentQuestion
.
options
;
this
.
count
=
0
;
let
posList
=
[
[
cc
.
v2
(
-
13
,
-
76
)
,
cc
.
v2
(
-
240
,
290
)
,
cc
.
v2
(
250
,
250
)
,
cc
.
v2
(
300
,
-
310
)
,
cc
.
v2
(
-
340
,
-
300
)
,
cc
.
v2
(
-
655
,
300
)
,
cc
.
v2
(
-
670
,
-
90
)
,
cc
.
v2
(
630
,
330
)
,
cc
.
v2
(
600
,
-
40
)
],
]
let
posArr
=
posList
[
0
];
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
let
data
=
list
[
i
]
let
item
=
cc
.
instantiate
(
paoaoParent
)
let
pos
=
posArr
[
i
];
layer_paopao
.
addChild
(
item
)
this
.
updatePaoPao
(
item
,
data
,
pos
);
}
this
.
scheduleOnce
(()
=>
{
this
.
canTouch
=
true
;
},
2
)
}
}
private
current
:
number
;
private
current
:
number
;
get
currentQuestion
()
{
get
currentQuestion
()
{
...
@@ -175,102 +152,196 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -175,102 +152,196 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
this
.
currentQuestion
.
options
.
filter
(
op
=>
op
.
right
);
return
this
.
currentQuestion
.
options
.
filter
(
op
=>
op
.
right
);
}
}
updatePaoPao
(
item
,
data
,
pos
)
{
let
bubble
=
item
.
getChildByName
(
"
bubble
"
)
let
broken
=
item
.
getChildByName
(
"
bubble_broken
"
)
let
img
=
bubble
.
getChildByName
(
"
img
"
)
let
text
=
bubble
.
getChildByName
(
"
text
"
)
let
img_broken
=
broken
.
getChildByName
(
"
img
"
)
let
text_broken
=
broken
.
getChildByName
(
"
text
"
)
pg
.
view
.
visible
(
broken
,
false
)
// 判断是显示图片还是文字
if
(
data
.
type
===
'
img
'
)
{
pg
.
view
.
visible
(
img
,
true
)
pg
.
view
.
visible
(
text
,
false
)
pg
.
view
.
setNetImg
(
img
,
data
.
image
,
{
w
:
180
,
h
:
160
})
pg
.
view
.
visible
(
img_broken
,
true
)
pg
.
view
.
visible
(
text_broken
,
false
)
pg
.
view
.
setNetImg
(
img_broken
,
data
.
image
,
{
w
:
180
,
h
:
160
})
}
else
{
pg
.
view
.
visible
(
img
,
false
)
pg
.
view
.
visible
(
text
,
true
)
pg
.
view
.
setString
(
text
,
data
.
text
)
pg
.
view
.
visible
(
img_broken
,
false
)
pg
.
view
.
visible
(
text_broken
,
true
)
pg
.
view
.
setString
(
text_broken
,
data
.
text
)
}
// 点击泡泡
item
.
data
=
data
;
pg
.
view
.
touchOn
(
item
,
this
.
touchPaoPao
,
this
)
pg
.
view
.
visible
(
item
,
true
)
item
.
x
=
pos
.
x
;
item
.
y
=
pos
.
y
-
1000
cc
.
tween
(
item
).
to
(
2
,
{
y
:
pos
.
y
}).
call
(()
=>
{
}).
start
();
}
// 点击泡泡
// 点击泡泡
touchPaoPao
(
e
:
any
)
{
touchPaoPao
(
e
:
any
)
{
// 如果泡泡没有到指定位置不允许点击
// 如果泡泡没有到指定位置不允许点击
let
item
=
e
.
target
;
let
item
=
e
.
target
;
let
data
=
e
.
target
.
data
;
let
data
=
e
.
target
.
data
;
if
(
data
.
right
)
{
if
(
data
.
right
)
{
cc
.
Tween
.
stopAllByTarget
(
item
)
// 成功 泡泡破碎 里面的内容消失
let
bubble
=
e
.
target
.
getChildByName
(
"
bubble
"
)
let
broken
=
e
.
target
.
getChildByName
(
"
bubble_broken
"
)
pg
.
view
.
visible
(
bubble
,
false
)
pg
.
view
.
visible
(
broken
,
true
)
pg
.
hw
.
playLocalAudio
(
'
light
'
)
cc
.
tween
(
item
).
delay
(
0.5
).
call
(()
=>
{
pg
.
hw
.
playLocalAudio
(
'
right
'
)
}).
by
(
0.5
,
{
y
:
1500
}).
start
();
this
.
rightList
.
push
(
data
);
this
.
rightList
.
push
(
data
);
// 处理剩余的节点
this
.
updatePaoPaoRight
(
item
,
data
).
then
(()
=>
{
if
(
this
.
rightList
.
length
==
this
.
currentRightList
.
length
)
{
let
layer_paopao
=
pg
.
view
.
find
(
this
,
'
layer_game/layer_paopao
'
)
let
children
=
layer_paopao
.
children
;
children
.
forEach
(
node
=>
{
if
(
this
.
rightList
.
some
(
dt
=>
node
.
data
.
id
==
dt
.
id
))
return
;
cc
.
tween
(
node
).
by
(
0.5
,
{
y
:
-
1500
}).
start
();
})
}
this
.
scheduleOnce
(()
=>
{
item
.
parent
=
null
;
if
(
this
.
rightList
.
length
==
this
.
currentRightList
.
length
)
{
if
(
this
.
rightList
.
length
==
this
.
currentRightList
.
length
)
{
this
.
freeArea
.
forEach
((
item
)
=>
{
this
.
udpatePaoPaoHide
(
item
);
})
cc
.
Tween
.
stopAll
();
cc
.
Tween
.
stopAll
();
this
.
startCreate
=
false
;
this
.
startCreate
=
false
;
this
.
nextQuestion
();
this
.
nextQuestion
();
}
}
}
,
1
);
}
)
}
else
{
}
else
{
// 失败
pg
.
hw
.
playLocalAudio
(
'
error
'
)
pg
.
hw
.
playLocalAudio
(
'
error
'
)
// 失败 泡泡左右微晃两次
this
.
updatePaoPaoError
(
item
,
data
)
cc
.
tween
(
pg
.
view
.
find
(
item
,
'
bubble
'
))
.
to
(
0.1
,
{
x
:
-
15
})
.
to
(
0.1
,
{
x
:
0
})
.
to
(
0.1
,
{
x
:
15
})
.
to
(
0.1
,
{
x
:
0
})
.
start
()
}
}
}
}
udpatePaoPaoHide
(
item
)
{
return
new
Promise
(
resolve
=>
{
let
bg_question
=
item
.
getChildByName
(
"
bg_question
"
)
let
img_mouse
=
bg_question
.
getChildByName
(
"
img_mouse
"
)
let
bg_pic
=
bg_question
.
getChildByName
(
"
bg_pic
"
)
let
bg_word
=
bg_question
.
getChildByName
(
"
bg_word
"
)
pg
.
view
.
visible
(
bg_pic
,
false
)
pg
.
view
.
visible
(
bg_word
,
false
)
pg
.
view
.
visible
(
img_mouse
,
false
)
resolve
(
""
);
})
}
updatePaoPaoRight
(
item
,
data
)
{
return
new
Promise
(
resolve
=>
{
let
bg_question
=
item
.
getChildByName
(
"
bg_question
"
)
let
img_mouse
=
bg_question
.
getChildByName
(
"
img_mouse
"
)
let
bg_pic
=
bg_question
.
getChildByName
(
"
bg_pic
"
)
let
bg_word
=
bg_question
.
getChildByName
(
"
bg_word
"
)
let
normal
=
img_mouse
.
getChildByName
(
"
normal
"
)
let
wrong
=
img_mouse
.
getChildByName
(
"
wrong
"
)
let
right
=
img_mouse
.
getChildByName
(
"
right
"
)
let
img
=
bg_pic
.
getChildByName
(
"
img
"
)
let
text
=
bg_word
.
getChildByName
(
"
text
"
)
pg
.
view
.
visible
(
normal
,
false
)
pg
.
view
.
visible
(
wrong
,
false
)
pg
.
view
.
visible
(
right
,
true
)
// 判断是显示图片还是文字
if
(
data
.
type
===
'
img
'
)
{
let
defaultPicY
=
-
170
;
let
outPicY
=
105
;
cc
.
Tween
.
stopAllByTarget
(
bg_pic
);
cc
.
tween
(
bg_pic
).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
else
{
let
defaultPicY
=
-
170
;
let
outPicY
=
80
;
cc
.
Tween
.
stopAllByTarget
(
bg_word
);
cc
.
tween
(
bg_word
).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
let
defaultMouseY
=
-
110
;
cc
.
Tween
.
stopAllByTarget
(
img_mouse
);
cc
.
tween
(
img_mouse
).
delay
(
1
).
to
(
1
,
{
y
:
defaultMouseY
}).
call
(()
=>
{
this
.
itemList
.
push
(
item
);
resolve
(
""
);
}).
start
();
})
}
updatePaoPaoError
(
item
,
data
)
{
return
new
Promise
(
resolve
=>
{
let
bg_question
=
item
.
getChildByName
(
"
bg_question
"
)
let
img_mouse
=
bg_question
.
getChildByName
(
"
img_mouse
"
)
let
bg_pic
=
bg_question
.
getChildByName
(
"
bg_pic
"
)
let
bg_word
=
bg_question
.
getChildByName
(
"
bg_word
"
)
let
normal
=
img_mouse
.
getChildByName
(
"
normal
"
)
let
wrong
=
img_mouse
.
getChildByName
(
"
wrong
"
)
let
right
=
img_mouse
.
getChildByName
(
"
right
"
)
let
img
=
bg_pic
.
getChildByName
(
"
img
"
)
let
text
=
bg_word
.
getChildByName
(
"
text
"
)
pg
.
view
.
visible
(
normal
,
false
)
pg
.
view
.
visible
(
wrong
,
true
)
pg
.
view
.
visible
(
right
,
false
)
// 判断是显示图片还是文字
if
(
data
.
type
===
'
img
'
)
{
let
defaultPicY
=
-
170
;
let
outPicY
=
105
;
cc
.
Tween
.
stopAllByTarget
(
bg_pic
);
cc
.
tween
(
bg_pic
).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
else
{
let
defaultPicY
=
-
170
;
let
outPicY
=
80
;
cc
.
Tween
.
stopAllByTarget
(
bg_word
);
cc
.
tween
(
bg_word
).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
let
defaultMouseY
=
-
110
;
cc
.
Tween
.
stopAllByTarget
(
img_mouse
);
cc
.
tween
(
img_mouse
).
delay
(
1
).
to
(
1
,
{
y
:
defaultMouseY
}).
call
(()
=>
{
this
.
itemList
.
push
(
item
);
this
.
dataList
.
push
(
data
);
resolve
(
""
);
}).
start
();
})
}
private
totalTime
;
private
count
:
number
;
private
time
;
@
property
([
cc
.
Node
])
private
freeArea
:
Array
<
cc
.
Node
>
=
[];
private
itemList
:
Array
<
cc
.
Node
>
=
[];
updateTime
()
{
updateTime
()
{
let
rand
=
Math
.
floor
(
Math
.
random
()
*
this
.
itemList
.
length
);
let
item
=
this
.
itemList
[
rand
];
let
rand2
=
Math
.
floor
(
Math
.
random
()
*
this
.
dataList
.
length
);
let
data
=
this
.
dataList
[
rand2
];
if
(
!
item
)
return
;
if
(
!
data
)
return
;
this
.
itemList
.
splice
(
rand
,
1
);
this
.
dataList
.
splice
(
rand2
,
1
);
// 1.选择某一个区域
// 2.出现老鼠,移除。
// 被打
// 1.停止动作,老鼠
// 2.继续播放动作,老鼠
//
this
.
updatePaoPao
(
item
,
data
);
}
updatePaoPao
(
item
,
data
)
{
let
bg_question
=
item
.
getChildByName
(
"
bg_question
"
)
let
img_mouse
=
bg_question
.
getChildByName
(
"
img_mouse
"
)
let
bg_pic
=
bg_question
.
getChildByName
(
"
bg_pic
"
)
let
bg_word
=
bg_question
.
getChildByName
(
"
bg_word
"
)
let
normal
=
img_mouse
.
getChildByName
(
"
normal
"
)
let
wrong
=
img_mouse
.
getChildByName
(
"
wrong
"
)
let
right
=
img_mouse
.
getChildByName
(
"
right
"
)
let
img
=
bg_pic
.
getChildByName
(
"
img
"
)
let
text
=
bg_word
.
getChildByName
(
"
text
"
)
pg
.
view
.
visible
(
normal
,
true
)
pg
.
view
.
visible
(
wrong
,
false
)
pg
.
view
.
visible
(
right
,
false
)
pg
.
view
.
visible
(
img_mouse
,
true
)
// 判断是显示图片还是文字
if
(
data
.
type
===
'
img
'
)
{
pg
.
view
.
setNetImg
(
img
,
data
.
image
,
{
w
:
295
,
h
:
195
})
let
defaultPicY
=
-
170
;
let
outPicY
=
105
;
bg_pic
.
active
=
true
;
cc
.
tween
(
bg_pic
).
to
(
1
,
{
y
:
outPicY
}).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
else
{
pg
.
view
.
setString
(
text
,
data
.
text
);
let
defaultPicY
=
-
170
;
let
outPicY
=
80
;
bg_word
.
active
=
true
;
cc
.
tween
(
bg_word
).
to
(
1
,
{
y
:
outPicY
}).
delay
(
1
).
to
(
1
,
{
y
:
defaultPicY
}).
start
();
}
// 点击泡泡
item
.
data
=
data
;
pg
.
view
.
touchOn
(
item
,
this
.
touchPaoPao
,
this
)
let
defaultMouseY
=
-
110
;
img_mouse
.
y
=
defaultMouseY
;
cc
.
tween
(
img_mouse
).
to
(
1
,
{
y
:
0
}).
delay
(
1
).
to
(
1
,
{
y
:
defaultMouseY
}).
call
(()
=>
{
this
.
itemList
.
push
(
item
);
this
.
dataList
.
push
(
data
);
}).
start
();
}
}
private
time
:
number
;
update
(
dt
)
{
update
(
dt
)
{
if
(
!
this
.
currentQuestion
)
return
;
if
(
!
this
.
currentQuestion
)
return
;
if
(
!
this
.
startCreate
)
return
;
if
(
!
this
.
startCreate
)
return
;
this
.
time
-=
dt
;
if
(
this
.
time
-=
dt
)
{
if
(
this
.
time
<=
0
)
{
if
(
this
.
time
<
0
)
{
console
.
log
(
"
游戏结束部分
"
)
this
.
time
=
1
;
this
.
nextQuestion
();
this
.
updateTime
();
return
;
}
}
}
this
.
updateTime
();
}
}
//----------------------------动画相关---------------------------------------------
//----------------------------动画相关---------------------------------------------
...
...
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