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
f86dcb7f
Commit
f86dcb7f
authored
Nov 26, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
a4c7a61c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+6
-3
Player.ts
assets/Scripts/Scenes/MainGame/Player.ts
+13
-1
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+11
-2
No files found.
assets/Bundles/MainGame/MainGame.scene
View file @
f86dcb7f
...
...
@@ -198,9 +198,9 @@
"_far": 2000,
"_color": {
"__type__": "cc.Color",
"r":
75
,
"g":
75
,
"b":
75
,
"r":
102
,
"g":
102
,
"b":
102
,
"a": 255
},
"_depth": 1,
...
...
@@ -1790,6 +1790,9 @@
"fastBtn": {
"__id__": 63
},
"camera": {
"__id__": 4
},
"_id": "2dUcPvKs9AvZqQZfZoDIZT"
},
{
...
...
assets/Scripts/Scenes/MainGame/Player.ts
View file @
f86dcb7f
import
{
_decorator
,
EventKeyboard
,
Input
,
input
,
KeyCode
,
director
,
_decorator
,
EventKeyboard
,
Input
,
input
,
KeyCode
,
director
,
Camera
,
lerp
,
}
from
"cc"
;
import
{
Snake
}
from
"./Snake"
;
...
...
@@ -19,6 +19,18 @@ export class Player extends Snake {
@
property
(
FastBtn
)
fastBtn
:
FastBtn
=
null
;
@
property
(
Camera
)
camera
:
Camera
=
null
;
get
scale
()
{
return
super
.
scale
;
}
set
scale
(
value
:
number
)
{
super
.
scale
=
value
;
this
.
camera
.
orthoHeight
=
lerp
(
275
,
612
,
value
);
}
get
length
():
number
{
return
super
.
length
;
}
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
f86dcb7f
...
...
@@ -56,7 +56,16 @@ export class Snake extends Component {
// 蛇的状态
isLife
:
boolean
=
false
;
private
scale
:
number
=
0.2
;
private
_scale
:
number
=
0.2
;
get
scale
()
{
return
this
.
_scale
;
}
set
scale
(
value
:
number
)
{
this
.
_scale
=
value
;
}
speed
:
number
=
300
;
private
energy
:
number
=
0
;
tag
:
number
=
0
;
...
...
@@ -202,11 +211,11 @@ export class Snake extends Component {
value
+=
this
.
lastRemaining
;
while
(
value
>=
growthThreshold
)
{
this
.
grow
();
value
-=
growthThreshold
;
if
(
this
.
scale
<
1
)
{
this
.
scale
+=
0.005
;
}
this
.
grow
();
}
this
.
lastRemaining
=
value
;
...
...
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