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
fabbf024
Commit
fabbf024
authored
Apr 23, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mrbr02完成
parent
00466056
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1156 additions
and
477 deletions
+1156
-477
layout_mouse.ts
assets/cocos_generator/mouse/layout_mouse.ts
+56
-0
layout_mouse.ts.meta
assets/cocos_generator/mouse/layout_mouse.ts.meta
+9
-0
Game.ts
assets/cocos_generator/scene/Game.ts
+2
-6
mrbr02.fire
assets/cocos_generator/scene/mrbr02.fire
+967
-457
mrbr02.ts
assets/cocos_generator/scene/mrbr02.ts
+107
-12
defaultData.ts
assets/cocos_generator/script/defaultData.ts
+15
-2
No files found.
assets/cocos_generator/mouse/layout_mouse.ts
0 → 100644
View file @
fabbf024
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
pg
from
"
../scene/pg
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
@
property
(
cc
.
Node
)
item
:
cc
.
Node
=
null
;
// LIFE-CYCLE CALLBACKS:
private
mouseList
=
[];
private
mouseNum
=
0
;
onLoad
()
{
pg
.
event
.
on
(
"
mouse_add
"
,
()
=>
{
this
.
reviceMouse
();
})
let
max
=
3
;
for
(
let
i
=
0
;
i
<
max
;
i
++
)
{
this
.
addMouse
();
}
}
reviceMouse
()
{
this
.
mouseNum
++
;
this
.
updateMouse
();
}
start
()
{
}
addMouse
()
{
let
item
=
cc
.
instantiate
(
this
.
item
);
item
.
active
=
true
;
item
.
getChildByName
(
"
light
"
).
active
=
false
;
this
.
node
.
addChild
(
item
);
this
.
mouseList
.
push
(
item
)
}
updateMouse
()
{
for
(
let
i
=
0
;
i
<
this
.
mouseList
.
length
;
i
++
)
{
let
item
=
this
.
mouseList
[
i
];
item
.
getChildByName
(
"
light
"
).
active
=
i
<
this
.
mouseNum
;
}
}
// update (dt) {}
}
assets/cocos_generator/mouse/layout_mouse.ts.meta
0 → 100644
View file @
fabbf024
{
"ver": "1.0.8",
"uuid": "aa1f1b26-6e7b-440a-9c1e-b2aa7f4e0d05",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/scene/Game.ts
View file @
fabbf024
...
...
@@ -89,14 +89,10 @@ export default class Game {
return
this
.
page
;
}
addPage
()
{
return
++
this
.
page
this
.
page
+=
1
;
}
get
isOver
()
{
let
times
=
0
;
// this.lists.forEach((li) => {
// times += li.stem.times;
// })
return
times
==
0
;
return
this
.
page
>
this
.
lists
.
length
;
}
}
...
...
assets/cocos_generator/scene/mrbr02.fire
View file @
fabbf024
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/mrbr02.ts
View file @
fabbf024
...
...
@@ -30,9 +30,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initEvent
();
pg
.
event
.
emit
(
"
startGame
"
);
}
@
property
(
cc
.
Node
)
ani_flower
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_card
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_card_result
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
node_card
:
cc
.
Node
=
null
;
...
...
@@ -50,30 +54,58 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
,
'
bg/bg_card/btn_check
'
),
this
.
onTouchCheck
,
this
);
pg
.
event
.
on
(
"
startGame
"
,
()
=>
{
this
.
startGame
()
})
pg
.
event
.
on
(
"
nextPage
"
,
()
=>
{
this
.
nextPage
()
})
pg
.
event
.
on
(
"
gameOver
"
,
()
=>
{
this
.
gameOver
()
})
}
//开始游戏
startGame
()
{
Game
.
getIns
().
reset
();
this
.
nextPage
();
}
nextPage
()
{
this
.
cards
=
[];
this
.
cardBgs
=
[];
this
.
currentCards
=
[];
Game
.
getIns
().
reset
();
//自动创建卡片
let
data
:
Item
=
Game
.
getIns
().
getCurrentPage
();
console
.
log
(
"
data->
"
+
data
);
//自动创建卡片
this
.
layout_card
.
active
=
true
;
this
.
layout_card_result
.
active
=
false
;
this
.
createCrads
(
data
);
}
getCurrentOpSet
()
{
let
op
=
{
"
2
"
:
{
x
:
-
135
,
y
:
160
,
y2
:
-
80
,
space
:
260
,
scale
:
1
,
},
"
3
"
:
{
x
:
-
260
,
y
:
160
,
y2
:
-
80
,
space
:
260
,
scale
:
1
,
}
},
"
4
"
:
{
x
:
-
390
,
y
:
110
,
y2
:
-
100
,
space
:
260
,
scale
:
0.85
,
},
"
5
"
:
{
x
:
-
410
,
y
:
110
,
y2
:
-
90
,
space
:
260
*
0.8
,
scale
:
0.8
,
},
}
let
opSet
=
op
[
`
${
Game
.
getIns
().
getCurrentPage
().
optionList
.
length
}
`
];
let
len
=
Game
.
getIns
().
getCurrentPage
().
optionList
.
length
;
let
opSet
=
op
[
`
${
len
}
`
];
return
opSet
;
}
getPostionById
(
count
)
{
...
...
@@ -93,6 +125,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
cards
:
cc
.
Node
[];
private
cardBgs
:
cc
.
Node
[];
createCrads
(
list
)
{
this
.
layout_card
.
removeAllChildren
();
let
count
=
0
;
list
.
optionList
.
forEach
(
li
=>
{
let
opSet
=
this
.
getCurrentOpSet
();
...
...
@@ -135,8 +168,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
break
;
case
"
picText
"
:
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
picText
'
),
true
);
pg
.
view
.
setString
(
pg
.
view
.
find
(
item
,
'
pic/label
'
),
data
.
txt
);
pg
.
view
.
setNetImg
(
pg
.
view
.
find
(
item
,
'
pic/img
'
),
data
.
picUrl
,
{
w
:
140
,
h
:
160
});
pg
.
view
.
setString
(
pg
.
view
.
find
(
item
,
'
pic
Text
/label
'
),
data
.
txt
);
pg
.
view
.
setNetImg
(
pg
.
view
.
find
(
item
,
'
pic
Text
/img
'
),
data
.
picUrl
,
{
w
:
140
,
h
:
160
});
break
;
}
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onItemTouchStart
,
this
);
...
...
@@ -153,14 +186,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
onItemTouchStart
(
e
)
{
let
target
:
cc
.
Node
=
e
.
target
;
let
data
=
target
.
data
;
console
.
log
(
target
);
let
location
=
e
.
getLocation
();
let
pos
=
location
.
sub
(
cc
.
v2
(
1280
/
2
,
720
/
2
))
e
.
target
.
setPosition
(
pos
)
}
onItemTouchMove
(
e
)
{
let
target
:
cc
.
Node
=
e
.
target
;
console
.
log
(
target
);
let
location
=
e
.
getLocation
();
let
pos
=
location
.
sub
(
cc
.
v2
(
1280
/
2
,
720
/
2
))
e
.
target
.
setPosition
(
pos
)
...
...
@@ -173,7 +204,6 @@ 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
));
})
console
.
log
(
itemBg
);
if
(
!
itemBg
||
this
.
currentCards
[
itemBg
.
data
.
id
])
{
//回退
target
.
setPosition
(
this
.
getPostionById
(
data
.
id
))
...
...
@@ -190,7 +220,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
pos
=
this
.
getBgPostionById
(
itemBg
.
data
.
id
);
target
.
setPosition
(
pos
);
this
.
currentCards
[
itemBg
.
data
.
id
]
=
target
;
this
.
updateCheckBtn
();
let
ani_flower
=
cc
.
instantiate
(
this
.
ani_flower
);
ani_flower
.
active
=
true
;
target
.
addChild
(
ani_flower
);
setTimeout
(()
=>
{
ani_flower
&&
(
ani_flower
.
parent
=
null
);
},
3000
);
}
onItemTouchCancel
()
{
}
...
...
@@ -203,11 +239,70 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
this
.
currentCards
.
length
!=
this
.
cards
.
length
)
return
false
;
return
this
.
currentCards
.
every
(
card
=>
!!
card
);
}
private
onTouchCheckCantouch
:
boolean
;
onTouchCheck
()
{
if
(
this
.
onTouchCheckCantouch
)
return
;
let
isSuccess
=
Game
.
getIns
().
checkSuccess
(
this
.
currentCards
.
map
(
cd
=>
cd
.
data
));
alert
(
isSuccess
);
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
();
})
this
.
currentCards
.
length
=
0
;
return
;
}
this
.
onTouchCheckCantouch
=
true
;
//成功更新小老鼠进度
//显示全部图片效果。
//显示棒棒糖
pg
.
event
.
emit
(
"
mouse_add
"
);
this
.
updateCardResult
().
then
(()
=>
{
Game
.
getIns
().
addPage
();
if
(
Game
.
getIns
().
isOver
)
{
pg
.
event
.
emit
(
"
gameOver
"
)
}
else
{
pg
.
event
.
emit
(
"
nextPage
"
)
}
this
.
onTouchCheckCantouch
=
false
;
})
}
updateCardResult
()
{
return
new
Promise
((
res
,
rej
)
=>
{
let
page
=
Game
.
getIns
().
getCurrentPage
();
if
(
page
.
audio
)
{
pg
.
audio
.
playAudioByUrl
(
page
.
audio
).
then
(()
=>
{
res
(
true
);
})
}
else
{
setTimeout
(()
=>
{
res
(
true
);
},
1000
);
}
if
(
!!
page
.
image
)
{
this
.
layout_card
.
active
=
false
;
this
.
layout_card_result
.
active
=
true
;
//执行效果
let
img
=
pg
.
view
.
find
(
this
.
layout_card_result
,
"
img
"
);
pg
.
view
.
setNetImg
(
img
,
page
.
image
,
{
w
:
340
,
h
:
150
})
}
})
}
update
()
{
this
.
updateCheckBtn
();
this
.
updateProgress
();
}
updateProgress
()
{
let
page
=
pg
.
view
.
find
(
this
,
'
bg/bg_card/page/label
'
);
pg
.
view
.
setString
(
page
,
Game
.
getIns
().
getCurrentPageNum
()
+
'
/
'
+
Game
.
getIns
().
getTotalPageNum
())
}
gameOver
()
{
let
mouse_end
=
pg
.
view
.
find
(
this
,
"
mouse_end
"
);
mouse_end
.
active
=
true
;
mouse_end
.
getComponent
(
"
mouse_end
"
).
play
().
then
(()
=>
{
onHomeworkFinish
();
})
}
playLocalAudio
(
audioName
)
{
...
...
assets/cocos_generator/script/defaultData.ts
View file @
fabbf024
...
...
@@ -5,10 +5,23 @@ export const defaultData = {
"
item
"
:
{
"
questionList
"
:
[
{
"
audio
"
:
""
,
"
image
"
:
""
,
"
optionList
"
:
[{
"
type
"
:
"
text
"
,
"
text
"
:
"
a
"
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/116fb7accb5428361836fbc46287f769.mp3
"
},
{
"
type
"
:
"
text
"
,
"
text
"
:
"
b
"
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/526624b47ba5e46f698add9e152a4b4e.mp3
"
},
{
"
type
"
:
"
text
"
,
"
text
"
:
""
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/fe2520ea0b12ad8c482595f6dddf8019.mp3
"
}]
"
audio
"
:
""
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/a5b6943a004bc48b07220f832853bd46.png
"
,
"
optionList
"
:
[
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
as
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/418486dc95e98b7d3f88f652c4716bbc.png
"
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/116fb7accb5428361836fbc46287f769.mp3
"
},
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
bs
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/476305ab6763e6821b34f66f1b6a59ed.png
"
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3
"
},
]
},
{
"
audio
"
:
""
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/a5b6943a004bc48b07220f832853bd46.png
"
,
"
optionList
"
:
[{
"
type
"
:
"
picText
"
,
"
text
"
:
"
as
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/418486dc95e98b7d3f88f652c4716bbc.png
"
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/116fb7accb5428361836fbc46287f769.mp3
"
},
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
bs
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/476305ab6763e6821b34f66f1b6a59ed.png
"
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610.mp3
"
},
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
cd
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/cda87159d3d022b6469b186e325c2bb6.png
"
,
"
optionAudio
"
:
""
},
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
dd
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/bb4244d166b6d077617ff089f7fd46c4.png
"
,
"
optionAudio
"
:
""
},
{
"
type
"
:
"
picText
"
,
"
text
"
:
"
ed
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/be64edcdfed05f4a61690207570f39d7.png
"
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/9df3f14bc88bcffc49b6717c40428ed8
.mp3
"
}]
"
audio
"
:
""
,
"
image
"
:
"
"
,
"
optionList
"
:
[{
"
type
"
:
"
text
"
,
"
text
"
:
"
a
"
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/116fb7accb5428361836fbc46287f769.mp3
"
},
{
"
type
"
:
"
text
"
,
"
text
"
:
"
b
"
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/526624b47ba5e46f698add9e152a4b4e.mp3
"
},
{
"
type
"
:
"
text
"
,
"
text
"
:
""
,
"
image
"
:
""
,
"
optionAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/fe2520ea0b12ad8c482595f6dddf8019
.mp3
"
}]
}
]
}
...
...
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