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
93babd5f
Commit
93babd5f
authored
Oct 26, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加word生成
parent
072d94db
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
241 additions
and
50 deletions
+241
-50
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+91
-48
cocos_generator.ts
assets/cocos_generator/scene/cocos_generator.ts
+133
-0
Game.ts
assets/cocos_generator/scene/tool/Game.ts
+16
-0
creator.d.ts
creator.d.ts
+1
-1
tsconfig.json
tsconfig.json
+0
-1
No files found.
assets/cocos_generator/scene/cocos_generator.fire
View file @
93babd5f
...
...
@@ -93,7 +93,7 @@
"__id__": 39
},
{
"__id__": 5
2
"__id__": 5
3
}
],
"_active": true,
...
...
@@ -1022,7 +1022,7 @@
"__uuid__": "8da4b052-dc5f-4ec5-880f-0487104c524b"
},
"_type": 0,
"_sizeMode":
1
,
"_sizeMode":
0
,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
...
...
@@ -1411,8 +1411,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-
872.208
,
295.276
,
-
676.319
,
1274.723
,
0,
0,
0,
...
...
@@ -1929,7 +1929,11 @@
}
],
"_active": true,
"_components": [],
"_components": [
{
"__id__": 52
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
...
...
@@ -1941,8 +1945,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"width":
11
0,
"height":
11
0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -1953,8 +1957,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
275.5
44,
-109.563
,
-410.8
44,
1311.419
,
0,
0,
0,
...
...
@@ -1980,7 +1984,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_keyboard_
b
",
"_name": "img_keyboard_
1
",
"_objFlags": 0,
"_parent": {
"__id__": 39
...
...
@@ -2074,7 +2078,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_keyboard_
o
",
"_name": "img_keyboard_
2
",
"_objFlags": 0,
"_parent": {
"__id__": 39
...
...
@@ -2168,7 +2172,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_keyboard_
p
",
"_name": "img_keyboard_
3
",
"_objFlags": 0,
"_parent": {
"__id__": 39
...
...
@@ -2262,7 +2266,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_keyboard_
g
",
"_name": "img_keyboard_
4
",
"_objFlags": 0,
"_parent": {
"__id__": 39
...
...
@@ -2356,7 +2360,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_keyboard_
y
",
"_name": "img_keyboard_
5
",
"_objFlags": 0,
"_parent": {
"__id__": 39
...
...
@@ -2545,6 +2549,76 @@
"_N$cacheMode": 0,
"_id": "a9geZOjwhOzolP6BmUqQKt"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 39
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 39
},
"_id": "a5CSFc15pHJrUqBqHzlHYf"
},
{
"__type__": "cc.Node",
"_name": "layout_words",
...
...
@@ -2554,11 +2628,7 @@
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 53
}
],
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
...
...
@@ -2582,8 +2652,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
574.248
,
-269.848
,
0
,
0
,
0,
0,
0,
...
...
@@ -2607,33 +2677,6 @@
"groupIndex": 0,
"_id": "6bgUStIA5IBZsfN73tkScS"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
},
"_enabled": false,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "a9lqlLNsFK9L1knW5VLscs"
},
{
"__type__": "cc.Canvas",
"_name": "",
...
...
assets/cocos_generator/scene/cocos_generator.ts
View file @
93babd5f
...
...
@@ -49,6 +49,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private
layout_blocks
:
cc
.
Node
;
private
layout_words
:
cc
.
Node
;
initBlocks
()
{
this
.
layout_blocks
=
pg
.
view
.
find
(
this
,
'
layout_blocks
'
);
this
.
layout_blocks
.
removeAllChildren
()
...
...
@@ -68,6 +69,138 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
gameStart
()
{
let
word
=
pg
.
view
.
find
(
this
,
'
word
'
);
this
.
layout_words
=
pg
.
view
.
find
(
this
,
'
layout_words
'
);
this
.
layout_words
.
removeAllChildren
()
let
words
=
GameNGT14
.
getIns
().
getCurrent
().
getWords
();
let
space
=
{
x
:
150
,
y
:
150
}
words
.
forEach
((
w
,
index
)
=>
{
let
node
=
cc
.
instantiate
(
word
);
let
data
=
w
;
if
(
index
<
5
)
{
node
.
x
=
280
+
space
.
x
*
index
node
.
y
=
-
110
}
else
if
(
index
<
9
)
{
node
.
x
=
355
+
space
.
x
*
(
index
-
5
)
node
.
y
=
-
110
-
space
.
y
;
}
else
{
node
.
x
=
280
+
space
.
x
*
(
index
-
9
)
node
.
y
=
-
110
-
space
.
y
*
2
;
}
this
.
layout_words
.
addChild
(
node
);
this
.
updateWord
(
node
,
data
);
});
}
updateWord
(
node
,
data
)
{
node
.
data
=
data
;
pg
.
view
.
setString
(
pg
.
view
.
find
(
node
,
'
label
'
),
data
);
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
);
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onItemTouchCancel
,
this
);
}
private
setTouchPos
(
e
)
{
let
item
=
e
.
target
;
let
location
=
e
.
getLocation
();
cc
.
Tween
.
stopAllByTarget
(
item
);
let
pos
=
location
.
sub
(
cc
.
v2
(
1920
/
2
,
1080
/
2
));
item
.
x
=
pos
.
x
;
item
.
y
=
pos
.
y
;
}
private
touching
:
any
;
onItemTouchStart
(
e
)
{
if
(
this
.
touching
)
return
;
let
target
:
cc
.
Node
=
e
.
target
;
let
data
:
string
=
target
.
data
;
this
.
setTouchPos
(
e
);
this
.
touching
=
data
;
}
onItemTouchMove
(
e
)
{
let
target
:
cc
.
Node
=
e
.
target
;
let
data
=
target
.
data
;
if
(
!
this
.
touching
)
return
;
if
(
this
.
touching
!=
data
)
return
;
this
.
setTouchPos
(
e
);
}
onItemTouchEnd
(
e
)
{
let
target
:
cc
.
Node
=
e
.
target
;
let
data
=
target
.
data
;
if
(
!
this
.
touching
)
return
;
if
(
this
.
touching
!=
data
)
return
;
// let rect = cc.rect(target.x, target.y, target.width, target.height);
let
rect
=
cc
.
rect
(
target
.
x
,
target
.
y
,
50
,
50
);
//坐标转换
console
.
log
(
"
1123123123
"
)
return
;
let
boat_left
=
pg
.
view
.
find
(
this
,
'
layout_bottom/boat_left
'
)
let
boat_right
=
pg
.
view
.
find
(
this
,
'
layout_bottom/boat_right
'
)
let
leftRect
=
cc
.
rect
(
boat_left
.
x
-
boat_left
.
width
/
2
,
boat_left
.
y
-
boat_left
.
height
/
2
,
boat_left
.
width
,
boat_left
.
height
);
let
rightRect
=
cc
.
rect
(
boat_right
.
x
-
boat_right
.
width
/
2
,
boat_right
.
y
-
boat_right
.
height
/
2
,
boat_right
.
width
,
boat_right
.
height
);
let
isRight
=
false
;
let
currentRect
=
null
;
// if (rect.intersects(leftRect)) {
// isRight = !!Game.getIns().boatLeft.isChild(data);
// Game.getIns().boatLeft.setRight(data);
// currentRect = leftRect;
// } else if (rect.intersects(rightRect)) {
// isRight = !!Game.getIns().boatRight.isChild(data);
// Game.getIns().boatRight.setRight(data);
// currentRect = rightRect;
// }
if
(
!
currentRect
)
{
this
.
touching
=
null
;
this
.
playLocalAudio
(
'
error
'
).
then
(()
=>
{
this
.
touching
=
null
;
// this.updateItem(target, data);
})
return
;
}
if
(
isRight
)
{
let
item
=
target
;
let
lastArea
=
100
;
// this.playLocalAudio('right').then(() => {
// if (data.audioUrl) {
// pg.audio.playAudioByUrlThen(data.audioUrl).then(() => {
// this.touching = null;
// })
// } else {
// this.touching = null;
// }
// })
if
(
item
.
scaleX
==
-
1
)
{
// 计算当前坐标距离最左侧的距离
let
space
=
currentRect
.
width
-
((
rect
.
x
+
rect
.
width
)
-
currentRect
.
x
)
-
lastArea
/
5
;
let
time
=
space
/
10
;
cc
.
tween
(
item
).
by
(
time
,
{
x
:
space
}).
start
();
}
else
{
// 计算当前坐标距离最左侧的距离
let
space
=
rect
.
x
-
currentRect
.
x
-
lastArea
;
let
time
=
space
/
10
;
cc
.
tween
(
item
).
by
(
time
,
{
x
:
-
space
}).
start
();
}
item
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onItemTouchStart
,
this
);
item
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onItemTouchMove
,
this
);
item
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onItemTouchEnd
,
this
);
item
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onItemTouchCancel
,
this
);
pg
.
event
.
emit
(
'
mouse_05_add
'
)
}
else
{
this
.
playLocalAudio
(
'
error
'
).
then
(()
=>
{
this
.
touching
=
null
;
// this.updateItem(target, data);
})
}
//判断是否结束了
// if (Game.getIns().boatLeft.isAllRight() && Game.getIns().boatRight.isAllRight()) {
// this.showGameOver();
// }
}
onItemTouchCancel
()
{
}
playLocalAudio
(
audioName
)
{
...
...
assets/cocos_generator/scene/tool/Game.ts
View file @
93babd5f
...
...
@@ -83,11 +83,27 @@ export class Question {
public
id
:
number
;
public
list
:
Array
<
Option
>
;
public
submit
:
BOARD_STATE
;
public
words
;
public
answer
;
constructor
(
data
)
{
this
.
id
=
Question
.
id
++
;
console
.
log
(
data
);
this
.
list
=
data
.
options
.
map
(
option
=>
new
Option
(
option
));
this
.
submit
=
BOARD_STATE
.
DEFAULT
this
.
answer
=
data
.
answer
this
.
words
=
data
.
answer
.
split
(
''
);
while
(
this
.
words
.
length
<
14
)
{
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
();
}
setSubmit
(
state
)
{
this
.
submit
=
state
...
...
creator.d.ts
View file @
93babd5f
...
...
@@ -4588,7 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward
:
Vec3
;
data
:
{
x
:
number
;
y
:
number
;
}
;
data
:
any
;
/**
@param name name
tsconfig.json
View file @
93babd5f
...
...
@@ -6,7 +6,6 @@
"experimentalDecorators"
:
true
,
"skipLibCheck"
:
true
,
"outDir"
:
"temp/vscode-dist"
,
"allowJs"
:
true
,
"forceConsistentCasingInFileNames"
:
true
},
"exclude"
:
[
...
...
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