Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy08_caici
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
hy08_caici
Commits
e41f742d
Commit
e41f742d
authored
Jul 12, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础整理
parent
1a487a13
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
611 additions
and
582 deletions
+611
-582
hy08_caici.fire
assets/hy08_caici/scene/hy08_caici.fire
+570
-570
hy08_caici.ts
assets/hy08_caici/scene/hy08_caici.ts
+41
-12
No files found.
assets/hy08_caici/scene/hy08_caici.fire
View file @
e41f742d
This diff is collapsed.
Click to expand it.
assets/hy08_caici/scene/hy08_caici.ts
View file @
e41f742d
...
...
@@ -35,6 +35,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this
.
initSysteam
();
this
.
initData
();
this
.
initView
();
this
.
initListener
();
...
...
@@ -44,9 +45,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
pg
.
event
.
emit
(
'
npc_layer_back_init
'
,
this
.
data
)
}
initSysteam
()
{
console
.
log
(
"
调用竖版
"
)
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
courseware
&&
courseware
.
onConfigurationPortrait
()
}
else
{
courseware
&&
courseware
.
onConfigurationPortrait
()
}
}
protected
onDestroy
():
void
{
pg
.
event
.
clear
();
courseware
.
onConfigurationLandscape
()
}
_cantouch
=
null
;
private
item_question
:
cc
.
Node
//题目id
private
currentId
:
number
//总时间时间
...
...
@@ -59,6 +71,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
layer_game
:
cc
.
Node
;
// 准备开始
private
layout_begin
:
cc
.
Node
;
private
layout_question
:
cc
.
Node
;
initData
()
{
// 所有全局变量 默认都是null
this
.
_cantouch
=
true
;
...
...
@@ -67,11 +80,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initView
()
{
// 取对象
/* this.item_question = pg.view.find(this, 'item_question'); */
this
.
layer_game
=
pg
.
view
.
find
(
this
,
'
layer_game
'
);
this
.
layout_begin
=
pg
.
view
.
find
(
this
.
layer_game
,
'
layout_begin
'
);
this
.
layout_question
=
pg
.
view
.
find
(
this
.
layer_game
,
'
layout_question
'
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
layer_game
,
'
countdown/countdown1
'
),
true
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
layer_game
,
'
countdown/countdown2
'
),
false
);
let
item_question
=
pg
.
view
.
find
(
this
,
'
layer_game/item_question
'
);
pg
.
view
.
visible
(
item_question
,
false
);
}
initListener
()
{
...
...
@@ -140,6 +155,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
//----------------------Question------------------------------------
private
currentTime
:
number
;
private
currentItemQuestion
:
cc
.
Node
;
private
nextItemQuestion
:
cc
.
Node
;
startQuestion
()
{
// 游戏所需的初始化数据
this
.
currentId
=
0
...
...
@@ -149,15 +166,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
right
=
0
this
.
gameStart
=
true
;
this
.
state
=
State
.
Recording
;
this
.
currentItemQuestion
=
this
.
createQuestionItem
(
cc
.
v2
(
0
,
50
));
this
.
updateQuestion
();
this
.
updateProgress
();
}
createQuestionItem
(
pos
)
{
let
item_question
=
pg
.
view
.
find
(
this
,
'
layer_game/item_question
'
);
let
clone_question
=
pg
.
view
.
clone
(
item_question
);
clone_question
.
active
=
true
;
clone_question
.
x
=
pos
.
x
;
clone_question
.
y
=
pos
.
y
;
this
.
layout_question
.
addChild
(
clone_question
);
return
clone_question
;
}
//题目
updateQuestion
()
{
let
item
_question
=
pg
.
view
.
find
(
this
,
'
layer_game/item_question
'
)
;
let
item
Question
=
this
.
currentItemQuestion
;
let
data
=
this
.
getCurrent
();
pg
.
view
.
setNetImg
(
pg
.
view
.
find
(
item
_q
uestion
,
"
img
"
),
data
.
image
,
{
w
:
700
,
h
:
360
})
pg
.
view
.
setString
(
pg
.
view
.
find
(
item
_q
uestion
,
"
text
"
),
data
.
text
)
pg
.
view
.
setNetImg
(
pg
.
view
.
find
(
item
Q
uestion
,
"
img
"
),
data
.
image
,
{
w
:
700
,
h
:
360
})
pg
.
view
.
setString
(
pg
.
view
.
find
(
item
Q
uestion
,
"
text
"
),
data
.
text
)
}
//------------------------------Loop----------------------------------
...
...
@@ -210,13 +240,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
//用户回答结果
checkRight
(
score
)
{
let
isRight
=
score
>
40
;
let
item_question
=
pg
.
view
.
find
(
this
,
'
layer_game/item_question
'
);
/*
* answer 获取的用户答案
*/
//判断对错
let
row
=
pg
.
view
.
find
(
this
,
'
layer_game/row
'
);
item_question
.
children
[
2
].
active
=
true
let
currentItemQuestion
=
this
.
currentItemQuestion
;
let
row
=
pg
.
view
.
find
(
currentItemQuestion
,
'
row
'
);
currentItemQuestion
.
children
[
2
].
active
=
true
//正确
if
(
isRight
)
{
//正确后执行函数
...
...
@@ -240,14 +270,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
hideAnswer
()
{
let
item_question
=
pg
.
view
.
find
(
this
,
'
layer_game/item_question
'
);
let
row
=
pg
.
view
.
find
(
this
,
'
layer_game/row
'
);
console
.
log
(
"
节点移出画面
"
)
let
currentItemQuestion
=
this
.
currentItemQuestion
;
let
row
=
pg
.
view
.
find
(
currentItemQuestion
,
'
row
'
);
let
right
=
pg
.
view
.
find
(
row
,
'
right
'
);
let
mistake
=
pg
.
view
.
find
(
row
,
'
mistake
'
);
let
text
=
pg
.
view
.
find
(
item_question
,
'
text
'
);
right
.
active
=
false
mistake
.
active
=
false
text
.
active
=
false
}
//------------------------------Record----------------------------------
...
...
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