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
953b0d58
Commit
953b0d58
authored
Oct 27, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础换色完成
parent
c31b11a3
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1332 additions
and
231 deletions
+1332
-231
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+1199
-173
cocos_generator.ts
assets/cocos_generator/scene/cocos_generator.ts
+91
-40
Game.ts
assets/cocos_generator/scene/tool/Game.ts
+33
-9
defaultData.ts
assets/cocos_generator/script/defaultData.ts
+3
-3
img_focus2.png
assets/cocos_generator/textures/czm/img_focus2.png
+0
-0
img_undone.png
assets/cocos_generator/textures/czm/img_undone.png
+0
-0
img_undone.png.meta
assets/cocos_generator/textures/czm/img_undone.png.meta
+6
-6
No files found.
assets/cocos_generator/scene/cocos_generator.fire
View file @
953b0d58
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/cocos_generator.ts
View file @
953b0d58
...
...
@@ -48,49 +48,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
initListener
()
{
}
private
layout_blocks
:
cc
.
Node
;
private
layout_words
:
cc
.
Node
;
initBlocks
()
{
this
.
layout_blocks
=
pg
.
view
.
find
(
this
,
'
layout_blocks
'
);
this
.
layout_blocks
.
removeAllChildren
()
let
block
=
pg
.
view
.
find
(
this
,
'
block
'
);
//动态创建,并给每一个打上编号
let
space
=
{
x
:
9
+
80
,
y
:
10
+
80
}
for
(
let
y
=
0
;
y
<
9
;
y
++
)
{
for
(
let
x
=
0
;
x
<
12
;
x
++
)
{
let
node
=
cc
.
instantiate
(
block
);
let
data
=
{
x
,
y
};
node
.
data
=
data
;
node
.
x
=
-
495
+
space
.
x
*
x
;
node
.
y
=
365
-
space
.
y
*
y
;
node
.
active
=
!!
GameNGT14
.
getIns
().
getBlockVal
(
x
,
y
);
this
.
layout_blocks
.
addChild
(
node
);
}
}
}
gameStart
()
{
this
.
updateQuestion
();
this
.
updateHightLight
();
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
);
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
'
));
getLayByOption
(
option
:
Option
,
base
,
{
onlyImg
,
showCenter
})
{
if
(
onlyImg
)
{
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_full
'
))
}
else
if
(
showCenter
)
{
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_center
'
))
}
else
{
return
option
.
isDoubleLine
()
?
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_double
'
))
:
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
layout_single
'
));
}
}
getNodeByBlock
(
block
:
Block
,
base
)
{
getNodeByBlock
(
block
:
Block
,
base
,
{
onlyImg
}
)
{
switch
(
block
.
type
)
{
case
BLOCK_TYPE
.
IMG
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
img
'
))
if
(
onlyImg
)
{
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
img_big
'
))
}
else
{
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
img
'
))
}
case
BLOCK_TYPE
.
TXT
:
return
cc
.
instantiate
(
pg
.
view
.
find
(
base
,
'
label
'
))
case
BLOCK_TYPE
.
LINE
:
...
...
@@ -103,19 +93,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
visible
(
item
,
true
);
item
.
data
=
data
;
let
board
=
pg
.
view
.
find
(
item
,
'
board
'
);
//
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
blocks
=
option
.
getList
();
let
showCenter
=
blocks
.
length
==
1
&&
blocks
[
0
].
type
==
BLOCK_TYPE
.
IMG
;
let
onlyImg
=
list
.
length
==
1
&&
showCenter
;
//确定使用的单双行
let
lay
=
this
.
getLayByOption
(
option
,
base
);
let
lay
=
this
.
getLayByOption
(
option
,
base
,
{
onlyImg
,
showCenter
}
);
pg
.
view
.
addChild
(
layout
,
lay
);
let
blocks
=
option
.
getList
();
blocks
.
forEach
(
block
=>
{
//确定使用哪种节点
let
node
=
this
.
getNodeByBlock
(
block
,
base
);
let
node
=
this
.
getNodeByBlock
(
block
,
base
,
{
onlyImg
});
node
.
y
=
0
;
pg
.
view
.
addChild
(
lay
,
node
);
this
.
updateNode
(
node
,
block
)
})
...
...
@@ -124,9 +117,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
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
;
...
...
@@ -146,11 +136,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
updateImg
(
item
,
block
:
Block
)
{
pg
.
view
.
setNetImg
(
item
,
block
.
img
,
{
w
:
253
,
h
:
174
})
pg
.
view
.
setNetImg
(
item
,
block
.
img
,
{
w
:
item
.
width
,
h
:
item
.
height
})
}
updateLine
(
item
,
block
:
Block
)
{
item
.
width
=
block
.
line
*
30
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
label/input_cursor
'
),
false
)
//
pg.view.visible(pg.view.find(item, 'label/input_cursor'), false)
// pg.view.touchOn(item, this.onTouchLine, this);
}
updateLabel
(
item
,
block
:
Block
)
{
...
...
@@ -162,7 +152,52 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
setString
(
pg
.
view
.
find
(
tag_default
,
'
label
'
),
block
.
tag
)
pg
.
view
.
setString
(
pg
.
view
.
find
(
tag_input
,
'
label
'
),
block
.
tag
)
}
//----------------------------------------左侧方块部分-----------------------------------
private
layout_blocks
:
cc
.
Node
;
initBlocks
()
{
this
.
layout_blocks
=
pg
.
view
.
find
(
this
,
'
layout_blocks
'
);
this
.
layout_blocks
.
removeAllChildren
()
let
block
=
pg
.
view
.
find
(
this
,
'
block
'
);
//动态创建,并给每一个打上编号
let
space
=
{
x
:
9
+
80
,
y
:
10
+
80
}
for
(
let
y
=
0
;
y
<
9
;
y
++
)
{
for
(
let
x
=
0
;
x
<
12
;
x
++
)
{
let
node
=
cc
.
instantiate
(
block
);
let
data
=
{
x
,
y
,
val
:
''
};
node
.
data
=
data
;
node
.
x
=
-
495
+
space
.
x
*
x
;
node
.
y
=
365
-
space
.
y
*
y
;
node
.
active
=
!!
GameNGT14
.
getIns
().
getBlockVal
(
x
,
y
);
this
.
layout_blocks
.
addChild
(
node
);
}
}
}
// 更新面板高亮
updateHightLight
()
{
let
list
=
GameNGT14
.
getIns
().
getHightList
();
let
first
=
null
;
this
.
layout_blocks
.
children
.
forEach
(
node
=>
{
let
point
=
node
.
data
;
if
(
list
.
some
(
li
=>
li
.
compare
(
point
)))
{
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_undone
'
),
false
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_focus
'
),
true
)
if
(
!
point
.
val
&&
!
first
)
{
first
=
true
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_focus2
'
),
true
)
}
}
else
{
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_undone
'
),
true
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_focus
'
),
false
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_focus2
'
),
false
)
}
})
}
getBlockNodeByPos
(
x
,
y
)
{
return
this
.
layout_blocks
.
children
.
find
(
node
=>
node
.
data
.
x
==
x
&&
node
.
data
.
y
==
y
)
}
//----------------------------------------右下角单词部分-----------------------------------
private
layout_words
:
cc
.
Node
;
updateWords
()
{
let
word
=
pg
.
view
.
find
(
this
,
'
word
'
);
this
.
layout_words
=
pg
.
view
.
find
(
this
,
'
layout_words
'
);
...
...
@@ -188,8 +223,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
updateWord
(
node
,
data
)
{
node
.
data
=
data
;
pg
.
view
.
setString
(
pg
.
view
.
find
(
node
,
'
label
'
),
data
);
node
.
rotation
=
data
.
rotation
pg
.
view
.
setString
(
pg
.
view
.
find
(
node
,
'
label
'
),
data
.
word
);
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
pg
.
view
.
visible
(
pg
.
view
.
find
(
node
,
'
img_keyboard_
'
+
i
),
data
.
color
==
i
);
}
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onItemTouchStart
,
this
);
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onItemTouchMove
,
this
);
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onItemTouchEnd
,
this
);
...
...
@@ -298,6 +336,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
assets/cocos_generator/scene/tool/Game.ts
View file @
953b0d58
...
...
@@ -80,13 +80,13 @@ export class Option {
}
export
class
Question
{
public
static
id
:
number
=
1000
;
public
id
:
number
;
public
id
:
string
;
public
list
:
Array
<
Option
>
;
public
submit
:
BOARD_STATE
;
public
words
;
public
answer
;
constructor
(
data
)
{
this
.
id
=
Question
.
id
++
;
this
.
id
=
data
.
id
;
console
.
log
(
data
);
this
.
list
=
data
.
options
.
map
(
option
=>
new
Option
(
option
));
this
.
submit
=
BOARD_STATE
.
DEFAULT
...
...
@@ -96,14 +96,22 @@ export class Question {
let
str
=
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
"
this
.
words
.
push
(
str
[
Math
.
floor
(
Math
.
random
()
*
str
.
length
)])
}
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
this
.
words
.
sort
((
A
,
B
)
=>
{
return
Math
.
random
()
<
0.5
})
}
}
getWords
()
{
return
this
.
words
.
concat
();
let
rand
=
Math
.
floor
(
Math
.
random
()
*
100
);
let
words
=
this
.
words
.
map
((
w
,
index
)
=>
{
return
{
word
:
w
,
color
:
(
index
+
rand
)
%
5
+
1
,
rotation
:
Math
.
random
()
<
0.5
?
3
:
-
3
}
});
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
words
.
sort
((
A
,
B
)
=>
{
return
Math
.
random
()
-
0.5
});
}
return
words
;
}
setSubmit
(
state
)
{
this
.
submit
=
state
...
...
@@ -124,6 +132,7 @@ export class Question {
export
class
GameNGT14
{
public
questions
:
Array
<
Question
>
public
blocks
:
Array
<
{
val
:
string
}
>
public
blockStruct
:
Array
<
{
pId
:
string
,
answer
:
string
,
point
:
{
x
:
number
,
y
:
number
}
}
>
public
current
:
number
;
public
title
:
string
;
public
total
:
number
;
...
...
@@ -140,6 +149,7 @@ export class GameNGT14 {
initData
(
data
)
{
console
.
log
(
data
);
this
.
questions
=
data
.
questions
[
0
].
parts
.
map
(
part
=>
new
Question
(
part
));
this
.
blockStruct
=
data
.
blockStruct
;
this
.
blocks
=
data
.
blocks
;
this
.
title
=
data
.
title
;
this
.
startAudio
=
data
.
startAudio
||
""
;
...
...
@@ -149,7 +159,21 @@ export class GameNGT14 {
if
(
!
this
.
blocks
[
y
]
||
!
this
.
blocks
[
y
][
x
])
return
;
return
this
.
blocks
[
y
][
x
].
val
;
}
getHightList
()
{
let
data
=
this
.
getCurrent
();
let
line
=
this
.
blockStruct
.
find
(
block
=>
block
.
pId
==
data
.
id
);
let
list
=
[];
for
(
let
i
=
0
;
i
<
line
.
answer
.
length
;
i
++
)
{
list
.
push
({
x
:
line
.
point
.
x
+
i
,
y
:
line
.
point
.
y
,
compare
:
function
(
p
)
{
return
this
.
x
==
p
.
x
&&
this
.
y
==
p
.
y
;
}
})
}
return
list
}
getCurrent
():
Question
{
return
this
.
questions
[
this
.
current
];
}
...
...
assets/cocos_generator/script/defaultData.ts
View file @
953b0d58
...
...
@@ -3,7 +3,7 @@ export const defaultData = {
{
"
parts
"
:
[{
"
id
"
:
"
166668702213640281
"
,
"
answer
"
:
"
freedo
w
"
,
"
answer
"
:
"
freedo
m
"
,
"
options
"
:
[
{
"
blocks
"
:
[
...
...
@@ -21,7 +21,7 @@ export const defaultData = {
},
{
"
blocks
"
:
[
{
"
type
"
:
"
txt
"
,
"
txt
"
:
""
,
"
line
"
:
""
,
"
img
"
:
""
,
"
tag
"
:
""
,
"
text
"
:
"
On saturdays freedo
w
"
"
type
"
:
"
txt
"
,
"
txt
"
:
""
,
"
line
"
:
""
,
"
img
"
:
""
,
"
tag
"
:
""
,
"
text
"
:
"
On saturdays freedo
m
"
}
]
}]
...
...
@@ -72,7 +72,7 @@ export const defaultData = {
{
"
pId
"
:
"
166668702213640281
"
,
"
point
"
:
{
"
x
"
:
3
,
"
y
"
:
6
},
"
answer
"
:
"
freedo
w
"
"
answer
"
:
"
freedo
m
"
},
{
"
pId
"
:
"
1666687612725869271
"
,
...
...
assets/cocos_generator/textures/czm/img_focus2.png
View replaced file @
c31b11a3
View file @
953b0d58
3.08 KB
|
W:
|
H:
1.66 KB
|
W:
|
H:
2-up
Swipe
Onion skin
assets/cocos_generator/textures/czm/img_undone.png
View replaced file @
c31b11a3
View file @
953b0d58
1.01 KB
|
W:
|
H:
1.49 KB
|
W:
|
H:
2-up
Swipe
Onion skin
assets/cocos_generator/textures/czm/img_undone.png.meta
View file @
953b0d58
...
...
@@ -7,8 +7,8 @@
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width":
79
,
"height":
79
,
"width":
82
,
"height":
83
,
"platformSettings": {},
"subMetas": {
"img_undone": {
...
...
@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width":
79
,
"height":
79
,
"rawWidth":
79
,
"rawHeight":
79
,
"width":
82
,
"height":
83
,
"rawWidth":
82
,
"rawHeight":
83
,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
...
...
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