Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MingSnake_241120
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
MingSnake_241120
Commits
b193474d
Commit
b193474d
authored
Nov 20, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
28c24165
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
18 deletions
+9
-18
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+5
-5
MainGame.ts
assets/Scripts/Scenes/MainGame/MainGame.ts
+3
-3
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+1
-10
No files found.
assets/Bundles/MainGame/MainGame.scene
View file @
b193474d
...
...
@@ -1064,8 +1064,8 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 1
63
,
"height": 1
81
"width": 1
00
,
"height": 1
00
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -1159,7 +1159,7 @@
"x": 0,
"y": 0
},
"_radius":
6
0,
"_radius":
5
0,
"_id": "35XBcgL4hOhYpj8xmXzP8l"
},
{
...
...
@@ -1174,8 +1174,8 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width":
4
0,
"height":
36
"width": 0,
"height":
0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
assets/Scripts/Scenes/MainGame/MainGame.ts
View file @
b193474d
...
...
@@ -185,7 +185,7 @@ export class MainGame extends Scene {
if
(
this
.
state
==
GameState
.
READY
)
return
;
// 更新UI提示
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
金币:
${
this
.
snake
.
getMoneySum
()
}
`
;
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
}`
;
this
.
snake
.
setAngle
((
360
-
this
.
joystick
.
angle
)
%
360
);
...
...
@@ -226,7 +226,7 @@ export class MainGame extends Scene {
break
;
case
GameState
.
WIN
:
director
.
pause
();
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
()
,
this
.
snake
.
getMoneySum
()
);
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
());
break
;
case
GameState
.
QUIT
:
director
.
resume
();
...
...
@@ -250,7 +250,7 @@ export class MainGame extends Scene {
}
showGOver
()
{
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
()
,
this
.
snake
.
getMoneySum
()
);
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
());
}
initItem
=
(
index
:
number
)
=>
{
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
b193474d
...
...
@@ -56,7 +56,6 @@ export class Snake extends Component {
private
speed
:
number
=
600
;
private
energy
:
number
=
0
;
private
tag
:
number
=
0
;
private
moneySum
:
number
=
0
;
// 位置相关
private
vw
:
number
=
Global
.
visibleSize
.
width
/
2
+
100
;
...
...
@@ -76,7 +75,6 @@ export class Snake extends Component {
await
this
.
setSkin
(
skinName
);
this
.
ready
=
false
;
this
.
moneySum
=
0
;
this
.
energy
=
0
;
this
.
bodyArr
=
[];
this
.
scale
=
scale
;
...
...
@@ -96,7 +94,7 @@ export class Snake extends Component {
collider
.
tag
=
this
.
tag
;
body
.
angle
=
angle
;
body
.
setPosition
(
-
9999
,
-
9999
);
body
.
setPosition
(
-
9999
9
,
-
9
9999
);
body
.
setScale
(
scale
,
scale
);
// 设置身体部分的贴图
...
...
@@ -117,7 +115,6 @@ export class Snake extends Component {
this
.
imgBody2
=
skin
.
getSpriteFrame
(
"body2"
);
}
onEnable
()
{
const
collider
=
this
.
head
.
getComponent
(
Collider2D
);
collider
.
on
(
Contact2DType
.
BEGIN_CONTACT
,
this
.
onBeginHead
,
this
);
...
...
@@ -152,8 +149,6 @@ export class Snake extends Component {
if
(
foodType
==
FoodType
.
FOOD
)
{
this
.
addEnergy
(
1
);
}
else
if
(
foodType
==
FoodType
.
MONEY
)
{
this
.
moneySum
+=
1
;
}
// 生成新的食物
...
...
@@ -295,10 +290,6 @@ export class Snake extends Component {
return
this
.
bodyArr
.
length
;
}
getMoneySum
()
{
return
this
.
moneySum
;
}
reInit
(
e
,
t
)
{
this
.
head
.
angle
=
0
;
this
.
head
.
setPosition
(
e
,
t
);
...
...
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