Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OP05
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
OP05
Commits
8cbd53f3
Commit
8cbd53f3
authored
Sep 22, 2021
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理流程
parent
daa178c4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
627 additions
and
748 deletions
+627
-748
gameManager.js
play/assets/scene/scene/gameManager.js
+25
-117
pg.js
play/assets/scene/scene/pg.js
+1
-16
scene.fire
play/assets/scene/scene/scene.fire
+471
-584
scene.js
play/assets/scene/scene/scene.js
+130
-31
No files found.
play/assets/scene/scene/gameManager.js
View file @
8cbd53f3
class
Single
{
constructor
()
{
this
.
imageani
=
{
ske
:
""
,
tex
:
""
,
png
:
""
,
}
this
.
wordani
=
{
ske
:
""
,
tex
:
""
,
png
:
""
,
}
this
.
wordaudio
=
""
;
this
.
backgroundImage
=
""
;
}
}
//底部items
class
Card
{
constructor
(
picItem
,
cardId
)
{
this
.
cardId
=
cardId
;
this
.
txt
=
picItem
.
title
;
this
.
img
=
picItem
.
pic_url
;
this
.
audio
=
picItem
.
audio_url
;
}
}
class
defClass
{
constructor
(
id
,
title
,
audio_url
,
type
)
{
this
.
id
=
id
;
this
.
audio_url
=
audio_url
;
this
.
type
=
type
;
this
.
title
=
title
;
this
.
child
=
[];
this
.
success
=
[];
}
addChild
(
child
)
{
this
.
child
.
push
(
child
);
}
isChild
(
childId
)
{
return
this
.
child
.
some
(
ch
=>
ch
.
id
==
childId
);
}
}
// class MainClass extends defaultClass {
// constructor(id, name) {
// this.id = id;
// this.name = name;
// }
// parseData() {
// }
// }
class
GameManager
{
class
GameManager
{
static
TYPE_NULL
=
0
;
static
TYPE_NULL
=
0
;
static
TYPE_TXT
=
1
;
static
TYPE_TXT
=
1
;
...
@@ -51,92 +8,43 @@ class GameManager {
...
@@ -51,92 +8,43 @@ class GameManager {
static
getIns
()
{
static
getIns
()
{
if
(
!
GameManager
.
instance
)
GameManager
.
instance
=
new
GameManager
();
if
(
!
GameManager
.
instance
)
GameManager
.
instance
=
new
GameManager
();
return
GameManager
.
instance
;
return
GameManager
.
instance
;
}
}
//允许调用
constructor
()
{
constructor
()
{
//主类 1
this
.
_list
=
[];
this
.
_title
=
{};
this
.
_stage
=
0
;
//关卡
this
.
_allClass
=
[];
this
.
_state
=
0
;
//状态
this
.
_sonArray
=
[];
//卡片数据解析
this
.
_cardArray
=
[];
//卡片数据解析
}
}
init
()
{
init
()
{
console
.
log
(
`init`
);
console
.
log
(
`init`
);
this
.
parseData
();
}
}
parseData
(
data
)
{
parseData
(
data
)
{
this
.
_title
=
{};
console
.
log
(
data
);
this
.
_allClass
=
[];
let
arr
=
data
.
contentObj
.
picArr
;
this
.
_sonArray
=
[];
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
this
.
_cardArray
=
[];
let
ar
=
arr
[
i
];
let
obj
=
{};
let
obj
=
data
.
contentObj
.
picArr
;
obj
.
word
=
ar
.
title
;
let
fenId
=
1
;
obj
.
sound
=
ar
.
wordAudio
;
let
sonId
=
100
;
obj
.
img
=
ar
.
bgImg
;
let
cardId
=
1000
;
obj
.
cartoonSke
=
ar
.
imgAni
.
ske
.
url
;
this
.
_title
=
obj
[
0
];
obj
.
cartoonTex
=
ar
.
imgAni
.
ske
.
url
;
for
(
let
i
=
0
;
i
<
obj
[
0
].
child
.
length
;
i
++
)
{
obj
.
cartoonPng
=
ar
.
imgAni
.
ske
.
url
;
let
zhulei
=
obj
[
0
].
child
[
i
];
this
.
_list
.
push
(
obj
);
let
zhuleiClass
=
new
defClass
(
zhulei
.
id
,
zhulei
.
title
,
zhulei
.
audio_url
,
0
);
for
(
let
a
=
0
;
a
<
zhulei
.
child
.
length
;
a
++
)
{
let
fenlei
=
zhulei
.
child
[
a
];
let
fenleiClass
=
new
defClass
(
fenId
,
fenlei
.
title
,
fenlei
.
audio_url
,
0
);
fenId
++
;
//只有1和2
for
(
let
b
=
0
;
b
<
fenlei
.
child
.
length
;
b
++
)
{
sonId
++
;
let
sonlei
=
fenlei
.
child
[
b
];
let
sonleiClass
=
new
defClass
(
sonId
,
sonlei
.
title
,
sonlei
.
audio_url
,
a
);
for
(
let
c
=
0
;
c
<
sonlei
.
child
.
length
;
c
++
)
{
let
card
=
sonlei
.
child
[
c
];
cardId
++
;
let
cardClass
=
new
Card
(
card
,
cardId
);
sonleiClass
.
addChild
(
cardClass
);
this
.
_cardArray
.
push
(
cardClass
);
}
fenleiClass
.
addChild
(
sonleiClass
);
}
zhuleiClass
.
addChild
(
fenleiClass
);
}
this
.
_allClass
.
push
(
zhuleiClass
);
}
}
console
.
log
(
this
.
_
allClass
);
console
.
log
(
this
.
_
list
);
//原始数据转为数组
}
}
getTitle
(
)
{
setState
(
num
)
{
return
this
.
_title
.
title
;
this
.
_state
=
num
;
}
}
get
ZhuClass
()
{
get
State
()
{
return
this
.
_
allClass
[
0
]
;
return
this
.
_
state
;
}
}
get
FenClass
(
id
)
{
get
StageData
(
)
{
return
this
.
_
allClass
[
0
].
child
.
filter
(
fen
=>
fen
.
id
==
id
)[
0
];
return
this
.
_
list
[
this
.
_stage
];
}
}
getSonClass
(
id
)
{
addStage
()
{
return
this
.
_sonArray
.
filter
(
son
=>
son
.
id
==
id
)[
0
];
this
.
_stage
++
;
}
getCards
()
{
//基础卡片列表
return
this
.
_cardArray
.
concat
();
}
compareCard
(
cardId
,
sonId
)
{
let
sonClass
=
this
.
getSonClass
(
sonId
);
return
sonClass
.
isChild
(
cardId
);
}
randomPageCards
()
{
//页面内部数字要打乱 0 1 2 3 4 5 6 7 8 每次动态取出一个值 然后动态处理
let
arr
=
[];
while
(
this
.
_cardArray
.
length
>
0
)
{
let
rand
=
Math
.
floor
(
Math
.
random
()
*
this
.
_cardArray
.
length
);
arr
.
push
(
this
.
_cardArray
[
rand
]);
this
.
_cardArray
.
splice
(
rand
,
1
);
}
this
.
_cardArray
=
arr
;
}
}
}
}
// []zhuclass
// [] []fenclass
//[] [] [] [] [] []sonclass
//[] [] [] [] [] []sonclass
//() () () () () () () ()card
//() () () () () () () ()
//() () () () () () () ()
export
default
GameManager
;
export
default
GameManager
;
\ No newline at end of file
play/assets/scene/scene/pg.js
View file @
8cbd53f3
...
@@ -252,21 +252,6 @@ pg.view = {
...
@@ -252,21 +252,6 @@ pg.view = {
//加载 未封装bundle
//加载 未封装bundle
pg
.
load
=
{
pg
.
load
=
{
loadRes
:
function
(
res
,
type
,
bundleName
)
{
loadRes
:
function
(
res
,
type
,
bundleName
)
{
// cc.assetManager.loadBundle('hall', (err, bundle) => {
// if (err) return cc.error(err);
// cc.director.loadScene("hall", () => { });
// });
// cc.assetManager.loadBundle('chess', (err, bundle) => {
// if (err) return cc.error(err);
// cc.director.loadScene("chess", () => {
// // //清理hall的资源
// // let hallBundle = cc.assetManager.getBundle(`hall`);
// // hallBundle.releaseAll();
// // cc.assetManager.removeBundle(hallBundle);
// });
// });
//此处需要二次封装,新的存在assetbundle
//此处需要二次封装,新的存在assetbundle
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
loader
.
loadRes
(
res
,
type
,
(
err
,
data
)
=>
{
cc
.
loader
.
loadRes
(
res
,
type
,
(
err
,
data
)
=>
{
...
@@ -294,7 +279,7 @@ pg.load = {
...
@@ -294,7 +279,7 @@ pg.load = {
},
},
loadNetImg
:
function
(
url
)
{
loadNetImg
:
function
(
url
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
loader
.
load
({
url
}
,
(
err
,
texture
)
=>
{
cc
.
assetManager
.
loadRemote
(
url
,
(
err
,
texture
)
=>
{
if
(
err
&&
!
data
)
return
resolve
(
pg
.
logger
.
w
(
'
loading loadRes warn->
'
,
res
));
if
(
err
&&
!
data
)
return
resolve
(
pg
.
logger
.
w
(
'
loading loadRes warn->
'
,
res
));
resolve
(
texture
);
resolve
(
texture
);
});
});
...
...
play/assets/scene/scene/scene.fire
View file @
8cbd53f3
This diff is collapsed.
Click to expand it.
play/assets/scene/scene/scene.js
View file @
8cbd53f3
...
@@ -157,32 +157,134 @@ cc.Class({
...
@@ -157,32 +157,134 @@ cc.Class({
_cardTouchItems
:
null
,
_cardTouchItems
:
null
,
_successItems
:
null
,
_successItems
:
null
,
initSingleData
()
{
initSingleData
()
{
this
.
_title
=
GameManager
.
getIns
().
getTitle
();
this
.
_stageData
=
GameManager
.
getIns
().
getStageData
();
this
.
_zhuClass
=
GameManager
.
getIns
().
getZhuClass
();
GameManager
.
getIns
().
setState
(
0
);
//调用数组中的数据,同时设置关卡状态为0
// console.log("1")
// 所有全局变量 默认都是null
// this._title = GameManager.getIns().getTitle();
this
.
_cantouch
=
0
;
// this._zhuClass = GameManager.getIns().getZhuClass();
//界面用数据
// // 所有全局变量 默认都是null
this
.
_cardTouchItems
=
[];
// this._cantouch = 0;
this
.
_successItems
=
[];
// //界面用数据
// this._cardTouchItems = [];
// this._successItems = [];
// this._cardPage = CardManager.getIns().getPage();
// this._cardPage = CardManager.getIns().getPage();
// cc.log(this._cardPage);
// cc.log(this._cardPage);
},
},
initAudio
()
{
initAudio
()
{
},
},
initView
()
{
initView
()
{
this
.
btn_replay
=
pg
.
view
.
find
(
this
,
"
btn_replay
"
);
// pg.view.visible(this.btn_replay, false);
pg
.
view
.
touchOn
(
this
.
btn_replay
,
this
.
onTouchReplay
,
this
);
this
.
initLayout
();
this
.
initLayout
();
this
.
initEvent
();
this
.
initStep1
();
},
},
initEvent
()
{
initLayout
()
{
let
btn_record
=
pg
.
view
.
find
(
this
,
"
btn_record
"
)
//按钮监听
let
btn_replay
=
pg
.
view
.
find
(
this
,
"
btn_replay
"
)
pg
.
view
.
touchOn
(
btn_record
,
this
.
onTouchIconRecord
,
this
);
let
btn_recording
=
pg
.
view
.
find
(
this
,
"
btn_recording
"
)
let
btn_record
=
pg
.
view
.
find
(
this
,
"
btn_record
"
)
let
progress
=
pg
.
view
.
find
(
this
,
"
progress
"
)
let
end
=
pg
.
view
.
find
(
this
,
"
end
"
);
let
end_success
=
pg
.
view
.
find
(
end
,
"
bg_success
"
)
let
bg_book
=
pg
.
view
.
find
(
this
,
"
bg_book
"
);
let
icon_ex
=
pg
.
view
.
find
(
this
,
"
icon_ex
"
);
let
btn_next
=
pg
.
view
.
find
(
this
,
"
btn_next
"
);
let
btn_return
=
pg
.
view
.
find
(
this
,
"
btn_return
"
);
let
icon_ex_txt
=
pg
.
view
.
find
(
icon_ex
,
"
txt
"
);
if
(
GameManager
.
getIns
().
getState
()
==
0
)
{
pg
.
view
.
visible
(
end
,
false
);
//不显示的内容用false
pg
.
view
.
visible
(
end_success
,
false
);
pg
.
view
.
visible
(
icon_ex
,
false
);
//更换书的样子
pg
.
view
.
visible
(
btn_next
,
true
);
//显示的内容用true
pg
.
view
.
visible
(
btn_return
,
true
);
let
bg_book_img
=
this
.
_stageData
.
img
;
//从数组中调取img数据
pg
.
view
.
setNetImg
(
bg_book
,
bg_book_img
);
//与界面的节点绑定
//创建一个动画 ---
//playAni().then(()=> { GameManager.getIns().setState(1); this.initLayout() } )
GameManager
.
getIns
().
setState
(
1
);
this
.
initLayout
()
//完成后直接进入下一步
}
else
if
(
GameManager
.
getIns
().
getState
()
==
1
)
{
setTimeout
(()
=>
{
pg
.
view
.
visible
(
icon_ex
,
true
);
let
icon_ex_word
=
this
.
_stageData
.
word
;
pg
.
view
.
setString
(
icon_ex_txt
,
icon_ex_word
);
},
1000
*
2
);
setTimeout
(()
=>
{
pg
.
view
.
visible
(
btn_record
,
true
);
pg
.
view
.
visible
(
btn_replay
,
true
);
pg
.
view
.
touchOn
(
btn_record
,
this
.
onTouchRecord
,
this
);
//注册按钮监听,从按钮里进入的下一步
},
1000
*
4
);
//显示文字动画
//播放文字的声音
//setTimeout(() => {
// GameManager.getIns().setState(2);
// this.initLayout()
//}, 1000 * 5);
//playAni().then(()=> { GameManager.getIns().setState(2); this.initLayout } )
}
else
if
(
GameManager
.
getIns
().
getState
()
==
2
)
{
pg
.
view
.
visible
(
btn_record
,
false
);
pg
.
view
.
visible
(
btn_replay
,
false
);
pg
.
view
.
visible
(
btn_recording
,
true
);
pg
.
view
.
visible
(
progress
,
true
);
setTimeout
(()
=>
{
GameManager
.
getIns
().
setState
(
3
);
this
.
initLayout
()
},
1000
*
4
);
//4秒钟之后进入下一步
}
else
if
(
GameManager
.
getIns
().
getState
()
==
3
)
{
pg
.
view
.
visible
(
btn_record
,
true
);
pg
.
view
.
visible
(
btn_recording
,
false
);
pg
.
view
.
visible
(
progress
,
false
);
setTimeout
(()
=>
{
pg
.
view
.
visible
(
end
,
true
);
pg
.
view
.
visible
(
end_success
,
true
);
},
1000
*
4
);
//4秒钟之后出现goodjob提示
setTimeout
(()
=>
{
this
.
nextStage
();
},
1000
*
6
);
//6秒钟之后进入下一关卡
}
else
if
(
GameManager
.
getIns
().
getState
()
==
4
)
{
}
else
if
(
GameManager
.
getIns
().
getState
()
==
5
)
{
}
else
if
(
GameManager
.
getIns
().
getState
()
==
6
)
{
}
// //根据当前显示用数据来执行对应的效果
// pg.view.setString(pg.view.find(this, "title/txt"), this._title);
// //刷新主类
// pg.view.setString(pg.view.find(this, "main/main/txt"), this._zhuClass.title);
// pg.view.touchOn(pg.view.find(this, "main/main"), this.onTouchVoice, this);
// pg.view.find(this, "main/main").data = this._zhuClass;
// //刷新分类
// pg.view.setString(pg.view.find(this, "main/sub_0/txt"), this._zhuClass.child[0].title);
// pg.view.setString(pg.view.find(this, "main/sub_1/txt"), this._zhuClass.child[1].title);
// pg.view.find(this, "main/sub_0").data = this._zhuClass.child[0];
// pg.view.find(this, "main/sub_1").data = this._zhuClass.child[1];
// pg.view.touchOn(pg.view.find(this, "main/sub_0"), this.onTouchVoice, this);
// pg.view.touchOn(pg.view.find(this, "main/sub_1"), this.onTouchVoice, this);
},
onTouchRecord
()
{
GameManager
.
getIns
().
setState
(
2
);
this
.
initLayout
()
},
nextStage
()
{
GameManager
.
getIns
().
addStage
();
//关卡标记+1
this
.
initSingleData
();
//刷新当前关卡所使用的的数据
this
.
initLayout
();
//刷新界面显示内容
},
},
onTouchIconRecord
()
{
onTouchIconRecord
()
{
let
btn_replay
=
pg
.
view
.
find
(
this
,
"
btn_replay
"
)
let
btn_replay
=
pg
.
view
.
find
(
this
,
"
btn_replay
"
)
let
btn_record
=
pg
.
view
.
find
(
this
,
"
btn_record
"
)
let
btn_record
=
pg
.
view
.
find
(
this
,
"
btn_record
"
)
...
@@ -226,21 +328,18 @@ cc.Class({
...
@@ -226,21 +328,18 @@ cc.Class({
},
},
initLayout
()
{
createAni
()
{
// //根据当前显示用数据来执行对应的效果
// cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err));
// pg.view.setString(pg.view.find(this, "title/txt"), this._title);
// //刷新主类
// pg.view.setString(pg.view.find(this, "main/main/txt"), this._zhuClass.title);
// pg.view.touchOn(pg.view.find(this, "main/main"), this.onTouchVoice, this);
// pg.view.find(this, "main/main").data = this._zhuClass;
// //刷新分类
// pg.view.setString(pg.view.find(this, "main/sub_0/txt"), this._zhuClass.child[0].title);
// pg.view.setString(pg.view.find(this, "main/sub_1/txt"), this._zhuClass.child[1].title);
// pg.view.find(this, "main/sub_0").data = this._zhuClass.child[0];
// pg.view.find(this, "main/sub_1").data = this._zhuClass.child[1];
// pg.view.touchOn(pg.view.find(this, "main/sub_0"), this.onTouchVoice, this);
// pg.view.touchOn(pg.view.find(this, "main/sub_1"), this.onTouchVoice, this);
},
},
//
//
onTouchVoice
(
touch
)
{
onTouchVoice
(
touch
)
{
let
item
=
touch
.
target
;
let
item
=
touch
.
target
;
...
...
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