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
Show 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 @@
...
@@ -1064,8 +1064,8 @@
"__prefab": null,
"__prefab": null,
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width": 1
63
,
"width": 1
00
,
"height": 1
81
"height": 1
00
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -1159,7 +1159,7 @@
...
@@ -1159,7 +1159,7 @@
"x": 0,
"x": 0,
"y": 0
"y": 0
},
},
"_radius":
6
0,
"_radius":
5
0,
"_id": "35XBcgL4hOhYpj8xmXzP8l"
"_id": "35XBcgL4hOhYpj8xmXzP8l"
},
},
{
{
...
@@ -1174,8 +1174,8 @@
...
@@ -1174,8 +1174,8 @@
"__prefab": null,
"__prefab": null,
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
4
0,
"width": 0,
"height":
36
"height":
0
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
...
assets/Scripts/Scenes/MainGame/MainGame.ts
View file @
b193474d
...
@@ -185,7 +185,7 @@ export class MainGame extends Scene {
...
@@ -185,7 +185,7 @@ export class MainGame extends Scene {
if
(
this
.
state
==
GameState
.
READY
)
return
;
if
(
this
.
state
==
GameState
.
READY
)
return
;
// 更新UI提示
// 更新UI提示
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
金币:
${
this
.
snake
.
getMoneySum
()
}
`
;
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
}`
;
this
.
snake
.
setAngle
((
360
-
this
.
joystick
.
angle
)
%
360
);
this
.
snake
.
setAngle
((
360
-
this
.
joystick
.
angle
)
%
360
);
...
@@ -226,7 +226,7 @@ export class MainGame extends Scene {
...
@@ -226,7 +226,7 @@ export class MainGame extends Scene {
break
;
break
;
case
GameState
.
WIN
:
case
GameState
.
WIN
:
director
.
pause
();
director
.
pause
();
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
()
,
this
.
snake
.
getMoneySum
()
);
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
());
break
;
break
;
case
GameState
.
QUIT
:
case
GameState
.
QUIT
:
director
.
resume
();
director
.
resume
();
...
@@ -250,7 +250,7 @@ export class MainGame extends Scene {
...
@@ -250,7 +250,7 @@ export class MainGame extends Scene {
}
}
showGOver
()
{
showGOver
()
{
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
()
,
this
.
snake
.
getMoneySum
()
);
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
());
}
}
initItem
=
(
index
:
number
)
=>
{
initItem
=
(
index
:
number
)
=>
{
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
b193474d
...
@@ -56,7 +56,6 @@ export class Snake extends Component {
...
@@ -56,7 +56,6 @@ export class Snake extends Component {
private
speed
:
number
=
600
;
private
speed
:
number
=
600
;
private
energy
:
number
=
0
;
private
energy
:
number
=
0
;
private
tag
:
number
=
0
;
private
tag
:
number
=
0
;
private
moneySum
:
number
=
0
;
// 位置相关
// 位置相关
private
vw
:
number
=
Global
.
visibleSize
.
width
/
2
+
100
;
private
vw
:
number
=
Global
.
visibleSize
.
width
/
2
+
100
;
...
@@ -76,7 +75,6 @@ export class Snake extends Component {
...
@@ -76,7 +75,6 @@ export class Snake extends Component {
await
this
.
setSkin
(
skinName
);
await
this
.
setSkin
(
skinName
);
this
.
ready
=
false
;
this
.
ready
=
false
;
this
.
moneySum
=
0
;
this
.
energy
=
0
;
this
.
energy
=
0
;
this
.
bodyArr
=
[];
this
.
bodyArr
=
[];
this
.
scale
=
scale
;
this
.
scale
=
scale
;
...
@@ -96,7 +94,7 @@ export class Snake extends Component {
...
@@ -96,7 +94,7 @@ export class Snake extends Component {
collider
.
tag
=
this
.
tag
;
collider
.
tag
=
this
.
tag
;
body
.
angle
=
angle
;
body
.
angle
=
angle
;
body
.
setPosition
(
-
9999
,
-
9999
);
body
.
setPosition
(
-
9999
9
,
-
9
9999
);
body
.
setScale
(
scale
,
scale
);
body
.
setScale
(
scale
,
scale
);
// 设置身体部分的贴图
// 设置身体部分的贴图
...
@@ -117,7 +115,6 @@ export class Snake extends Component {
...
@@ -117,7 +115,6 @@ export class Snake extends Component {
this
.
imgBody2
=
skin
.
getSpriteFrame
(
"body2"
);
this
.
imgBody2
=
skin
.
getSpriteFrame
(
"body2"
);
}
}
onEnable
()
{
onEnable
()
{
const
collider
=
this
.
head
.
getComponent
(
Collider2D
);
const
collider
=
this
.
head
.
getComponent
(
Collider2D
);
collider
.
on
(
Contact2DType
.
BEGIN_CONTACT
,
this
.
onBeginHead
,
this
);
collider
.
on
(
Contact2DType
.
BEGIN_CONTACT
,
this
.
onBeginHead
,
this
);
...
@@ -152,8 +149,6 @@ export class Snake extends Component {
...
@@ -152,8 +149,6 @@ export class Snake extends Component {
if
(
foodType
==
FoodType
.
FOOD
)
{
if
(
foodType
==
FoodType
.
FOOD
)
{
this
.
addEnergy
(
1
);
this
.
addEnergy
(
1
);
}
else
if
(
foodType
==
FoodType
.
MONEY
)
{
this
.
moneySum
+=
1
;
}
}
// 生成新的食物
// 生成新的食物
...
@@ -295,10 +290,6 @@ export class Snake extends Component {
...
@@ -295,10 +290,6 @@ export class Snake extends Component {
return
this
.
bodyArr
.
length
;
return
this
.
bodyArr
.
length
;
}
}
getMoneySum
()
{
return
this
.
moneySum
;
}
reInit
(
e
,
t
)
{
reInit
(
e
,
t
)
{
this
.
head
.
angle
=
0
;
this
.
head
.
angle
=
0
;
this
.
head
.
setPosition
(
e
,
t
);
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