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
accfd0ff
Commit
accfd0ff
authored
Nov 26, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
37868293
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1431 additions
and
106 deletions
+1431
-106
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+1178
-106
倒计时背景.png
assets/Bundles/MainGame/png/倒计时背景.png
+0
-0
倒计时背景.png.meta
assets/Bundles/MainGame/png/倒计时背景.png.meta
+134
-0
Target.ts
assets/Scripts/Scenes/MainGame/Components/Target.ts
+110
-0
Target.ts.meta
assets/Scripts/Scenes/MainGame/Components/Target.ts.meta
+9
-0
No files found.
assets/Bundles/MainGame/MainGame.scene
View file @
accfd0ff
This diff is collapsed.
Click to expand it.
assets/Bundles/MainGame/png/倒计时背景.png
0 → 100644
View file @
accfd0ff
881 Bytes
assets/Bundles/MainGame/png/倒计时背景.png.meta
0 → 100644
View file @
accfd0ff
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "c43af500-7323-4cfa-9738-490f627d956a",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "c43af500-7323-4cfa-9738-490f627d956a@6c48a",
"displayName": "倒计时背景",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "c43af500-7323-4cfa-9738-490f627d956a",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "c43af500-7323-4cfa-9738-490f627d956a@f9941",
"displayName": "倒计时背景",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 240,
"height": 60,
"rawWidth": 240,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-120,
-30,
0,
120,
-30,
0,
-120,
30,
0,
120,
30,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
60,
240,
60,
0,
0,
240,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-120,
-30,
0
],
"maxPos": [
120,
30,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "c43af500-7323-4cfa-9738-490f627d956a@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "c43af500-7323-4cfa-9738-490f627d956a@6c48a"
}
}
assets/Scripts/Scenes/MainGame/Components/Target.ts
0 → 100644
View file @
accfd0ff
import
{
_decorator
,
Component
,
Graphics
,
math
,
misc
,
Node
}
from
"cc"
;
const
{
ccclass
,
property
,
executeInEditMode
}
=
_decorator
;
@
ccclass
(
"Target"
)
@
executeInEditMode
()
export
class
Target
extends
Component
{
@
property
(
Graphics
)
graphics
:
Graphics
=
null
;
start
()
{
// this.graphics.clear();
// this.graphics.moveTo(120, 0);
// this.graphics.lineTo(120, -51);
// this.graphics.arc(110, -51, 10, 0, -Math.PI / 2, false);
// this.graphics.lineTo(-110, -61);
// this.graphics.arc(-110, -51, 10, -Math.PI / 2, -Math.PI, false);
// this.graphics.lineTo(-120, 0);
// this.graphics.stroke();
this
.
drawProcess
(
0.5
);
}
drawProcess
=
(()
=>
{
const
phases
=
[
51
,
Math
.
PI
/
2
*
10
,
220
,
Math
.
PI
/
2
*
10
,
51
,
];
const
totalLength
=
phases
.
reduce
((
a
,
b
,
i
)
=>
{
phases
[
i
]
=
a
+
b
;
return
phases
[
i
];
},
0
);
// Tip: 注意此时phases的结果
return
(
process
:
number
)
=>
{
// Ensure process is between 0 and 1
process
=
misc
.
clampf
(
process
,
0
,
1
);
this
.
graphics
.
clear
();
const
targetLength
=
totalLength
*
process
;
let
currentLength
=
0
;
this
.
graphics
.
moveTo
(
120
,
0
);
// Draw vertical line on right
const
rightVertical
=
Math
.
min
(
51
,
targetLength
-
currentLength
);
if
(
rightVertical
>
0
)
{
this
.
graphics
.
lineTo
(
120
,
-
rightVertical
);
currentLength
+=
rightVertical
;
if
(
currentLength
>=
targetLength
)
{
this
.
graphics
.
stroke
();
return
;
}
}
// Draw right arc
const
rightArcLength
=
Math
.
PI
*
10
/
2
;
if
(
targetLength
>
currentLength
)
{
const
rightArcAngle
=
Math
.
min
((
targetLength
-
currentLength
)
/
10
,
Math
.
PI
/
2
);
this
.
graphics
.
arc
(
110
,
-
51
,
10
,
0
,
-
rightArcAngle
,
false
);
currentLength
+=
rightArcLength
;
if
(
currentLength
>=
targetLength
)
{
this
.
graphics
.
stroke
();
return
;
}
}
// Draw horizontal line
const
horizontalLength
=
Math
.
min
(
220
,
targetLength
-
currentLength
);
if
(
horizontalLength
>
0
)
{
this
.
graphics
.
lineTo
(
-
110
+
(
220
-
horizontalLength
),
-
61
);
currentLength
+=
horizontalLength
;
if
(
currentLength
>=
targetLength
)
{
this
.
graphics
.
stroke
();
return
;
}
}
// Draw left arc
const
leftArcLength
=
Math
.
PI
*
10
/
2
;
if
(
targetLength
>
currentLength
)
{
const
leftArcAngle
=
Math
.
min
((
targetLength
-
currentLength
)
/
10
,
Math
.
PI
/
2
);
this
.
graphics
.
arc
(
-
110
,
-
51
,
10
,
-
Math
.
PI
/
2
,
-
Math
.
PI
/
2
-
leftArcAngle
,
false
);
currentLength
+=
leftArcLength
;
if
(
currentLength
>=
targetLength
)
{
this
.
graphics
.
stroke
();
return
;
}
}
// Draw vertical line on left
const
leftVertical
=
Math
.
min
(
51
,
targetLength
-
currentLength
);
if
(
leftVertical
>
0
)
{
this
.
graphics
.
lineTo
(
-
120
,
-
51
+
leftVertical
);
}
this
.
graphics
.
stroke
();
};
})();
update
(
deltaTime
:
number
)
{
}
}
assets/Scripts/Scenes/MainGame/Components/Target.ts.meta
0 → 100644
View file @
accfd0ff
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "63008b8e-06df-47eb-8e3b-a37571c9f16f",
"files": [],
"subMetas": {},
"userData": {}
}
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