Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MRBR02
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
MRBR02
Commits
6bf0994a
Commit
6bf0994a
authored
Apr 23, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mrbr02增加棒棒糖效果 打乱
parent
fabbf024
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
472 additions
and
473 deletions
+472
-473
mstart.ts
assets/cocos_generator/mouse/start/mstart.ts
+9
-17
Game.ts
assets/cocos_generator/scene/Game.ts
+12
-1
mrbr02.fire
assets/cocos_generator/scene/mrbr02.fire
+360
-442
mrbr02.ts
assets/cocos_generator/scene/mrbr02.ts
+89
-12
defaultData.ts
assets/cocos_generator/script/defaultData.ts
+2
-1
No files found.
assets/cocos_generator/mouse/start/mstart.ts
View file @
6bf0994a
...
...
@@ -28,14 +28,20 @@ export default class MouseStart extends cc.Component {
this
.
ske
.
x
=
this
.
startPosition
.
x
;
this
.
ske
.
y
=
this
.
startPosition
.
y
;
}
play
()
{
play
(
audioUrl
?:
string
)
{
this
.
moveInTime
=
Game
.
getIns
().
aniEnter
.
time
||
5
;
return
new
Promise
((
resolve
,
reject
)
=>
{
let
isPlaying
=
true
;
this
.
ske
.
x
=
this
.
startPosition
.
x
;
this
.
ske
.
y
=
this
.
startPosition
.
y
;
this
.
ske
.
active
=
true
;
this
.
node
.
active
=
true
;
this
.
block
.
active
=
true
;
pg
.
load
.
loadDB
(
this
.
ske
,
{
ske
:
Game
.
getIns
().
aniEnter
.
skeJsonData
.
url
,
tex
:
Game
.
getIns
().
aniEnter
.
texJsonData
.
url
,
png
:
Game
.
getIns
().
aniEnter
.
texPngData
.
url
}).
then
((
animationName
)
=>
{
cc
.
tween
(
this
.
ske
).
to
(
1.3
,
{
x
:
this
.
targetPosition
.
x
,
y
:
this
.
targetPosition
.
y
}).
call
(()
=>
{
if
(
Game
.
getIns
().
aniEnter
.
audioUrl
)
{
this
.
playAudioByUrl
(
Game
.
getIns
().
aniEnter
.
audioUrl
,
()
=>
{
audioUrl
=
audioUrl
?
audioUrl
:
Game
.
getIns
().
aniEnter
.
audioUrl
;
if
(
audioUrl
)
{
pg
.
audio
.
playAudioByUrl
(
audioUrl
).
then
(()
=>
{
isPlaying
=
false
;
resolve
(
''
);
})
...
...
@@ -56,18 +62,4 @@ export default class MouseStart extends cc.Component {
})
});
}
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
cb
();
});
}
});
}
else
{
cb
&&
cb
();
}
}
}
assets/cocos_generator/scene/Game.ts
View file @
6bf0994a
...
...
@@ -5,6 +5,7 @@ export class Option {
audioUrl
;
public
data
;
public
id
:
number
;
public
count
:
number
;
constructor
(
data
,
id
)
{
this
.
id
=
id
;
this
.
data
=
data
;
...
...
@@ -23,9 +24,18 @@ export class Item {
this
.
audio
=
data
.
audio
;
this
.
image
=
data
.
image
;
let
id
=
0
;
this
.
optionList
=
data
.
optionList
.
map
(
o
=>
{
return
new
Option
(
o
,
id
++
);
})
this
.
optionList
.
sort
(
function
()
{
return
(
0.5
-
Math
.
random
());
});
for
(
let
i
=
0
;
i
<
this
.
optionList
.
length
;
i
++
)
{
this
.
optionList
[
i
].
count
=
i
;
}
this
.
page
=
page
;
}
}
...
...
@@ -65,7 +75,8 @@ export default class Game {
}
checkSuccess
(
arr
:
Option
[])
{
let
data
=
this
.
getCurrentPage
();
let
options
=
data
.
optionList
;
let
options
=
data
.
optionList
.
concat
();
options
.
sort
((
A
,
B
)
=>
A
.
id
-
B
.
id
)
for
(
let
i
=
0
;
i
<
options
.
length
;
i
++
)
{
if
(
arr
[
i
]
&&
arr
[
i
].
id
!=
options
[
i
].
id
)
{
return
false
;
...
...
assets/cocos_generator/scene/mrbr02.fire
View file @
6bf0994a
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/mrbr02.ts
View file @
6bf0994a
...
...
@@ -44,6 +44,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
bg_card
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_lollipop
:
cc
.
Node
=
null
;
initData
()
{
Game
.
getIns
().
init
(
this
.
data
);
}
...
...
@@ -58,6 +61,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
on
(
"
gameOver
"
,
()
=>
{
this
.
gameOver
()
})
}
private
currentCards
:
cc
.
Node
[];
//开始游戏
startGame
()
{
Game
.
getIns
().
reset
();
...
...
@@ -71,6 +75,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
//自动创建卡片
this
.
layout_card
.
active
=
true
;
this
.
layout_card_result
.
active
=
false
;
this
.
layout_lollipop
.
active
=
false
;
this
.
createCrads
(
data
);
}
getCurrentOpSet
()
{
...
...
@@ -126,6 +131,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
cardBgs
:
cc
.
Node
[];
createCrads
(
list
)
{
this
.
layout_card
.
removeAllChildren
();
let
count
=
0
;
list
.
optionList
.
forEach
(
li
=>
{
let
opSet
=
this
.
getCurrentOpSet
();
...
...
@@ -182,7 +188,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
item
.
data
=
data
item
.
active
=
true
;
}
private
currentCards
:
cc
.
Node
[];
onItemTouchStart
(
e
)
{
let
target
:
cc
.
Node
=
e
.
target
;
let
data
=
target
.
data
;
...
...
@@ -204,9 +209,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
itemBg
=
this
.
cardBgs
.
find
(
bg
=>
{
return
rect1
.
intersects
(
cc
.
rect
(
bg
.
x
,
bg
.
y
,
bg
.
width
*
bg
.
scale
,
bg
.
height
*
bg
.
scale
));
})
if
(
!
itemBg
||
this
.
currentCards
[
itemBg
.
data
.
id
])
{
if
(
!
itemBg
||
this
.
currentCards
[
itemBg
.
data
.
count
])
{
//回退
target
.
setPosition
(
this
.
getPostionById
(
data
.
id
))
target
.
setPosition
(
this
.
getPostionById
(
data
.
count
))
for
(
let
i
=
0
;
i
<
this
.
currentCards
.
length
;
i
++
)
{
let
cd
=
this
.
currentCards
[
i
];
if
(
cd
&&
cd
.
data
.
id
==
target
.
data
.
id
)
{
...
...
@@ -217,9 +222,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
}
//执行
let
pos
=
this
.
getBgPostionById
(
itemBg
.
data
.
id
);
let
pos
=
this
.
getBgPostionById
(
itemBg
.
data
.
count
);
target
.
setPosition
(
pos
);
this
.
currentCards
[
itemBg
.
data
.
id
]
=
target
;
this
.
currentCards
[
itemBg
.
data
.
count
]
=
target
;
let
ani_flower
=
cc
.
instantiate
(
this
.
ani_flower
);
ani_flower
.
active
=
true
;
...
...
@@ -236,6 +241,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
,
'
bg/bg_card/btn_check_grey
'
),
!
isFull
)
}
checkFull
()
{
if
(
!
this
.
currentCards
)
return
;
if
(
!
this
.
cards
)
return
;
if
(
this
.
currentCards
.
length
!=
this
.
cards
.
length
)
return
false
;
return
this
.
currentCards
.
every
(
card
=>
!!
card
);
}
...
...
@@ -245,17 +252,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
isSuccess
=
Game
.
getIns
().
checkSuccess
(
this
.
currentCards
.
map
(
cd
=>
cd
.
data
));
if
(
!
isSuccess
)
{
this
.
currentCards
.
forEach
(
card
=>
{
cc
.
tween
(
card
).
to
(
0.3
,
{
x
:
this
.
getPostionById
(
card
.
data
.
id
).
x
,
y
:
this
.
getPostionById
(
card
.
data
.
id
).
y
}).
start
();
cc
.
tween
(
card
).
to
(
0.3
,
{
x
:
this
.
getPostionById
(
card
.
data
.
count
).
x
,
y
:
this
.
getPostionById
(
card
.
data
.
count
).
y
}).
start
();
})
this
.
currentCards
.
length
=
0
;
return
;
}
this
.
onTouchCheckCantouch
=
true
;
//成功更新小老鼠进度
//显示全部图片效果。
//显示棒棒糖
pg
.
event
.
emit
(
"
mouse_add
"
);
this
.
updateCardResult
().
then
(()
=>
{
this
.
updateCardResult
().
then
(
this
.
updateLollipop
.
bind
(
this
)).
then
(
()
=>
{
Game
.
getIns
().
addPage
();
if
(
Game
.
getIns
().
isOver
)
{
pg
.
event
.
emit
(
"
gameOver
"
)
...
...
@@ -268,10 +272,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
updateCardResult
()
{
return
new
Promise
((
res
,
rej
)
=>
{
let
page
=
Game
.
getIns
().
getCurrentPage
();
//显示小老鼠
if
(
page
.
audio
)
{
pg
.
audio
.
playAudioByUrl
(
page
.
audio
).
then
(()
=>
{
pg
.
view
.
find
(
this
,
"
mouse_start
"
).
getComponent
(
"
mstart
"
).
play
(
page
.
audio
).
then
(()
=>
{
res
(
true
);
})
})
;
}
else
{
setTimeout
(()
=>
{
res
(
true
);
...
...
@@ -286,6 +292,77 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
})
}
updateLollipop
()
{
return
new
Promise
((
res
,
rej
)
=>
{
//出现棒棒糖的部分。
//1.波浪。
//2.倒计时转圈
//3.弹出goodJob
//4.resolve
this
.
layout_lollipop
.
active
=
true
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
icon
'
).
active
=
true
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
texts
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_red
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_grey
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_highlight
'
).
active
=
false
;
let
vs
=
[
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
v1
'
),
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
v2
'
),
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
v3
'
)]
//出现波浪
let
count
=
0
;
let
i1
=
setInterval
(()
=>
{
count
++
;
let
max
=
count
%
(
vs
.
length
+
2
);
vs
[
0
].
active
=
1
<
max
;
vs
[
1
].
active
=
2
<
max
;
vs
[
2
].
active
=
3
<
max
;
},
200
)
let
lolliTouch
=
()
=>
{
clearInterval
(
i1
);
vs
[
0
].
active
=
false
;
vs
[
1
].
active
=
false
;
vs
[
2
].
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_red
'
).
active
=
true
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_grey
'
).
active
=
true
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_highlight
'
).
active
=
true
;
pg
.
view
.
touchOff
(
this
.
layout_lollipop
,
lolliTouch
,
this
);
let
progressbar_red
=
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_red
'
);
let
sprite
=
progressbar_red
.
getComponent
(
cc
.
Sprite
);
sprite
.
fillRange
=
1
;
let
i2
=
setInterval
(()
=>
{
sprite
.
fillRange
-=
0.005
;
},
30
)
setTimeout
(()
=>
{
clearInterval
(
i2
);
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
icon
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_red
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_grey
'
).
active
=
false
;
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
progressbar_highlight
'
).
active
=
false
;
let
texts
=
pg
.
view
.
find
(
this
.
layout_lollipop
,
'
texts
'
)
texts
.
active
=
true
;
let
complate
=
texts
.
getChildByName
(
"
complate
"
);
let
well
=
texts
.
getChildByName
(
"
well
"
);
let
good
=
texts
.
getChildByName
(
"
good
"
);
complate
.
active
=
false
;
well
.
active
=
false
;
good
.
active
=
false
;
let
words
=
[
complate
,
well
,
good
];
let
item
=
words
[
Math
.
floor
(
Math
.
random
()
*
words
.
length
)];
item
.
active
=
true
;
item
.
opacity
=
0
;
item
.
scale
=
0.1
;
cc
.
tween
(
item
).
to
(
0.2
,
{
scale
:
1.1
,
opacity
:
255
}).
to
(
0.1
,
{
scale
:
1
}).
delay
(
0.5
).
to
(
0.1
,
{
opacity
:
0
,
scale
:
0
}).
call
(()
=>
{
this
.
layout_lollipop
.
active
=
false
;
res
(
true
);
}).
start
();
},
3000
);
}
pg
.
view
.
touchOn
(
this
.
layout_lollipop
,
lolliTouch
,
this
);
})
}
update
()
{
this
.
updateCheckBtn
();
...
...
assets/cocos_generator/script/defaultData.ts
View file @
6bf0994a
...
...
@@ -5,7 +5,8 @@ export const defaultData = {
"
item
"
:
{
"
questionList
"
:
[
{
"
audio
"
:
""
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/a5b6943a004bc48b07220f832853bd46.png
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/116fb7accb5428361836fbc46287f769.mp3
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/a5b6943a004bc48b07220f832853bd46.png
"
,
"
optionList
"
:
[
{
"
type
"
:
"
picText
"
,
...
...
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