Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
ngt14_czm
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
ngt14_czm
Commits
c31b11a3
Commit
c31b11a3
authored
Oct 27, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理数据
parent
93babd5f
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1035 additions
and
192 deletions
+1035
-192
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+938
-190
cocos_generator.ts
assets/cocos_generator/scene/cocos_generator.ts
+96
-1
pg.ts
assets/cocos_generator/scene/tool/pg.ts
+1
-1
No files found.
assets/cocos_generator/scene/cocos_generator.fire
View file @
c31b11a3
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/cocos_generator.ts
View file @
c31b11a3
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
pg
from
"
./tool/pg
"
;
import
pg
from
"
./tool/pg
"
;
import
{
GameNGT14
}
from
"
./tool/Game
"
;
import
{
Block
,
BLOCK_TYPE
,
GameNGT14
,
Question
,
Option
}
from
"
./tool/Game
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -69,6 +69,101 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -69,6 +69,101 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
}
}
gameStart
()
{
gameStart
()
{
this
.
updateQuestion
();
this
.
updateWords
();
}
private
layout_question
:
cc
.
Node
;
updateQuestion
()
{
let
data
=
GameNGT14
.
getIns
().
getCurrent
();
this
.
layout_question
=
pg
.
view
.
find
(
this
,
'
layout_question
'
);
let
img_big
=
pg
.
view
.
find
(
this
.
layout_question
,
'
base/img_big
'
);
let
img_small
=
pg
.
view
.
find
(
this
.
layout_question
,
'
base/img_small
'
);
let
label_big
=
pg
.
view
.
find
(
this
.
layout_question
,
'
base/label_big
'
);
let
label_small
=
pg
.
view
.
find
(
this
.
layout_question
,
'
base/label_small
'
);
// 需要处理数据
this
.
updateItem
(
this
.
layout_question
,
data
);
}
getLayByOption
(
option
:
Option
,
base
)
{
return
option
.
isDoubleLine
()
?
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_double
'
))
:
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_single
'
));
}
getNodeByBlock
(
block
:
Block
,
base
)
{
switch
(
block
.
type
)
{
case
BLOCK_TYPE
.
IMG
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
img
'
))
case
BLOCK_TYPE
.
TXT
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
label
'
))
case
BLOCK_TYPE
.
LINE
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
line
'
))
case
BLOCK_TYPE
.
TAG
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
tag
'
))
}
}
updateItem
(
item
,
data
:
Question
)
{
pg
.
view
.
visible
(
item
,
true
);
item
.
data
=
data
;
let
board
=
pg
.
view
.
find
(
item
,
'
board
'
);
let
base
=
pg
.
view
.
find
(
item
,
'
base
'
);
// 确定基础layout
let
layout
=
pg
.
view
.
find
(
item
,
'
layout
'
);
let
list
:
Array
<
Option
>
=
data
.
getList
();
list
.
forEach
(
option
=>
{
//确定使用的单双行
let
lay
=
this
.
getLayByOption
(
option
,
base
);
pg
.
view
.
addChild
(
layout
,
lay
);
let
blocks
=
option
.
getList
();
blocks
.
forEach
(
block
=>
{
//确定使用哪种节点
let
node
=
this
.
getNodeByBlock
(
block
,
base
);
pg
.
view
.
addChild
(
lay
,
node
);
this
.
updateNode
(
node
,
block
)
})
})
setTimeout
(()
=>
{
let
height
=
layout
.
height
;
item
.
height
=
height
+
15
;
},
0
);
// pg.view.touchOn(item, this.onTouchItem, this)
// let btn_ok = pg.view.find(item, 'btn_ok');
// pg.view.touchOn(btn_ok, this.onTouchOk, this)
}
updateNode
(
item
,
block
:
Block
)
{
item
.
data
=
block
;
switch
(
block
.
type
)
{
case
BLOCK_TYPE
.
IMG
:
this
.
updateImg
(
item
,
block
)
break
case
BLOCK_TYPE
.
TXT
:
this
.
updateLabel
(
item
,
block
)
break
case
BLOCK_TYPE
.
LINE
:
this
.
updateLine
(
item
,
block
)
break
case
BLOCK_TYPE
.
TAG
:
this
.
updateTag
(
item
,
block
)
break
}
}
updateImg
(
item
,
block
:
Block
)
{
pg
.
view
.
setNetImg
(
item
,
block
.
img
,
{
w
:
253
,
h
:
174
})
}
updateLine
(
item
,
block
:
Block
)
{
item
.
width
=
block
.
line
*
30
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
label/input_cursor
'
),
false
)
// pg.view.touchOn(item, this.onTouchLine, this);
}
updateLabel
(
item
,
block
:
Block
)
{
pg
.
view
.
setString
(
item
,
block
.
text
)
}
updateTag
(
item
,
block
:
Block
)
{
let
tag_default
=
pg
.
view
.
find
(
item
,
'
tag_default
'
)
let
tag_input
=
pg
.
view
.
find
(
item
,
'
tag_input
'
)
pg
.
view
.
setString
(
pg
.
view
.
find
(
tag_default
,
'
label
'
),
block
.
tag
)
pg
.
view
.
setString
(
pg
.
view
.
find
(
tag_input
,
'
label
'
),
block
.
tag
)
}
updateWords
()
{
let
word
=
pg
.
view
.
find
(
this
,
'
word
'
);
let
word
=
pg
.
view
.
find
(
this
,
'
word
'
);
this
.
layout_words
=
pg
.
view
.
find
(
this
,
'
layout_words
'
);
this
.
layout_words
=
pg
.
view
.
find
(
this
,
'
layout_words
'
);
this
.
layout_words
.
removeAllChildren
()
this
.
layout_words
.
removeAllChildren
()
...
...
assets/cocos_generator/scene/tool/pg.ts
View file @
c31b11a3
...
@@ -131,7 +131,7 @@ let pg = {
...
@@ -131,7 +131,7 @@ let pg = {
return
node
;
return
node
;
},
},
//添加节点
//添加节点
addChild
(
item
,
child
,
zIndex
)
{
addChild
(
item
,
child
,
zIndex
=
0
)
{
if
(
!
child
)
return
console
.
log
(
"
addChild error ->请传入子节点
"
);
if
(
!
child
)
return
console
.
log
(
"
addChild error ->请传入子节点
"
);
if
(
!
item
)
return
console
.
log
(
"
addChild error ->请传入父节点
"
);
if
(
!
item
)
return
console
.
log
(
"
addChild error ->请传入父节点
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
let
node
=
item
.
node
?
item
.
node
:
item
;
...
...
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