Commit 28c24165 authored by haiyoucuv's avatar haiyoucuv

init

parent 25358c2f
......@@ -190,7 +190,7 @@
"_priority": 40000,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 947.8725099601594,
"_orthoHeight": 975.3705179282869,
"_near": 0,
"_far": 2000,
"_color": {
......@@ -875,7 +875,7 @@
"__type__": "Item",
"type": 0,
"sp": {
"__uuid__": "8f21f897-8cb9-448d-a674-e0574c83e228@da8cd",
"__uuid__": "74a5a14c-636e-4b82-a474-43ef9ca6a905@f9941",
"__expectedType__": "cc.SpriteFrame"
}
},
......@@ -1094,10 +1094,7 @@
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "8f21f897-8cb9-448d-a674-e0574c83e228@9296f",
"__expectedType__": "cc.SpriteFrame"
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
......@@ -1197,7 +1194,7 @@
},
"_enabled": true,
"__prefab": null,
"Head": {
"head": {
"__id__": 27
},
"bodyPrefab": {
......@@ -1293,7 +1290,7 @@
"joystick": {
"__id__": 38
},
"fashBtn": {
"fastBtn": {
"__id__": 46
},
"uiBg": {
......@@ -1512,7 +1509,7 @@
"_priority": 50000,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 947.8725099601594,
"_orthoHeight": 975.3705179282869,
"_near": 1,
"_far": 2000,
"_color": {
......@@ -1641,7 +1638,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "57520716-48c8-4a19-8acf-41c9f8777fb0@f9941",
"__uuid__": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
......@@ -2028,7 +2025,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "8f21f897-8cb9-448d-a674-e0574c83e228@da8cd",
"__uuid__": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
......@@ -2089,7 +2086,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "8f21f897-8cb9-448d-a674-e0574c83e228@7ca68",
"__uuid__": "74a5a14c-636e-4b82-a474-43ef9ca6a905@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
......
......@@ -169,10 +169,7 @@
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "57520716-48c8-4a19-8acf-41c9f8777fb0@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
......@@ -312,7 +309,6 @@
"Head": {
"__id__": 2
},
"water": null,
"bodyPrefab": {
"__uuid__": "8c4f22c7-20c7-4868-88ea-dedb8004999f",
"__expectedType__": "cc.Prefab"
......
......@@ -115,10 +115,7 @@
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "8f21f897-8cb9-448d-a674-e0574c83e228@da8cd",
"__expectedType__": "cc.SpriteFrame"
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
......
......@@ -2,7 +2,7 @@
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "43c3d349-8e95-48ea-bf1a-e9de526864af",
"uuid": "0d8d3b9f-f695-4e4b-b6cb-969a79079832",
"files": [
".json",
".png"
......@@ -10,14 +10,14 @@
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"displayName": "s0",
"uuid": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@6c48a",
"displayName": "body1",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af",
"imageUuidOrDatabaseUri": "0d8d3b9f-f695-4e4b-b6cb-969a79079832",
"isUuid": true,
"visible": false,
"minfilter": "linear",
......@@ -34,8 +34,8 @@
},
"f9941": {
"importer": "sprite-frame",
"uuid": "43c3d349-8e95-48ea-bf1a-e9de526864af@f9941",
"displayName": "s0",
"uuid": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@f9941",
"displayName": "body1",
"id": "f9941",
"name": "spriteFrame",
"userData": {
......@@ -43,13 +43,13 @@
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"offsetY": 1.5,
"trimX": 0,
"trimY": 0,
"width": 493,
"height": 193,
"rawWidth": 493,
"rawHeight": 193,
"width": 100,
"height": 100,
"rawWidth": 100,
"rawHeight": 103,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......@@ -61,17 +61,17 @@
"meshType": 0,
"vertices": {
"rawPosition": [
-246.5,
-96.5,
-50,
-50,
0,
246.5,
-96.5,
50,
-50,
0,
-246.5,
96.5,
-50,
50,
0,
246.5,
96.5,
50,
50,
0
],
"indexes": [
......@@ -84,37 +84,37 @@
],
"uv": [
0,
193,
493,
193,
103,
100,
103,
0,
0,
493,
0
3,
100,
3
],
"nuv": [
0,
0,
0.02912621359223301,
1,
0,
0.02912621359223301,
0,
1,
1,
1
],
"minPos": [
-246.5,
-96.5,
-50,
-50,
0
],
"maxPos": [
246.5,
96.5,
50,
50,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"imageUuidOrDatabaseUri": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
......@@ -129,6 +129,6 @@
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a"
"redirect": "0d8d3b9f-f695-4e4b-b6cb-969a79079832@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "74a5a14c-636e-4b82-a474-43ef9ca6a905",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "74a5a14c-636e-4b82-a474-43ef9ca6a905@6c48a",
"displayName": "body2",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "74a5a14c-636e-4b82-a474-43ef9ca6a905",
"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": "74a5a14c-636e-4b82-a474-43ef9ca6a905@f9941",
"displayName": "body2",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0.5,
"trimX": 0,
"trimY": 1,
"width": 100,
"height": 100,
"rawWidth": 100,
"rawHeight": 103,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-50,
-50,
0,
50,
-50,
0,
-50,
50,
0,
50,
50,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
102,
100,
102,
0,
2,
100,
2
],
"nuv": [
0,
0.019417475728155338,
1,
0.019417475728155338,
0,
0.9902912621359223,
1,
0.9902912621359223
],
"minPos": [
-50,
-50,
0
],
"maxPos": [
50,
50,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "74a5a14c-636e-4b82-a474-43ef9ca6a905@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "74a5a14c-636e-4b82-a474-43ef9ca6a905@6c48a"
}
}
......@@ -9,13 +9,13 @@
<key>aliases</key>
<array/>
<key>spriteOffset</key>
<string>{0,0}</string>
<string>{0,1}</string>
<key>spriteSize</key>
<string>{100,100}</string>
<string>{100,101}</string>
<key>spriteSourceSize</key>
<string>{100,100}</string>
<string>{100,103}</string>
<key>textureRect</key>
<string>{{290,84},{100,100}}</string>
<string>{{1,211},{100,101}}</string>
<key>textureRotated</key>
<false/>
</dict>
......@@ -26,11 +26,11 @@
<key>spriteOffset</key>
<string>{0,0}</string>
<key>spriteSize</key>
<string>{100,100}</string>
<string>{100,103}</string>
<key>spriteSourceSize</key>
<string>{100,100}</string>
<string>{100,103}</string>
<key>textureRect</key>
<string>{{392,84},{100,100}}</string>
<string>{{1,1},{100,103}}</string>
<key>textureRotated</key>
<false/>
</dict>
......@@ -41,41 +41,11 @@
<key>spriteOffset</key>
<string>{0,0}</string>
<key>spriteSize</key>
<string>{163,181}</string>
<key>spriteSourceSize</key>
<string>{163,181}</string>
<key>textureRect</key>
<string>{{125,1},{163,181}}</string>
<key>textureRotated</key>
<false/>
</dict>
<key>tait1.png</key>
<dict>
<key>aliases</key>
<array/>
<key>spriteOffset</key>
<string>{0,0}</string>
<key>spriteSize</key>
<string>{164,81}</string>
<key>spriteSourceSize</key>
<string>{164,81}</string>
<key>textureRect</key>
<string>{{290,1},{164,81}}</string>
<key>textureRotated</key>
<false/>
</dict>
<key>tait2.png</key>
<dict>
<key>aliases</key>
<array/>
<key>spriteOffset</key>
<string>{0,0}</string>
<key>spriteSize</key>
<string>{191,122}</string>
<string>{103,100}</string>
<key>spriteSourceSize</key>
<string>{191,122}</string>
<string>{103,100}</string>
<key>textureRect</key>
<string>{{1,1},{191,122}}</string>
<string>{{1,106},{103,100}}</string>
<key>textureRotated</key>
<true/>
</dict>
......@@ -89,13 +59,13 @@
<key>premultiplyAlpha</key>
<false/>
<key>realTextureFileName</key>
<string>s0.png</string>
<string>default.png</string>
<key>size</key>
<string>{493,193}</string>
<string>{102,313}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:6735ea558f0aa7c64bd9e92da816ca23:4da33dda424e9dfc0ce663f9309a5b05:a66884bb0e575156b3af2630252c8c2f$</string>
<string>$TexturePacker:SmartUpdate:e0a7963ab6250bee46680d49eb7b1ca1:156dc7ba41f81cd1436f4ce3a9b505a3:d258758acfd7c2dc4f771a427c5ecb8e$</string>
<key>textureFileName</key>
<string>s0.png</string>
<string>default.png</string>
</dict>
</dict>
</plist>
......@@ -2,14 +2,14 @@
"ver": "1.0.8",
"importer": "sprite-atlas",
"imported": true,
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228",
"uuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35",
"files": [
".json"
],
"subMetas": {
"da8cd": {
"importer": "sprite-frame",
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228@da8cd",
"uuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35@da8cd",
"displayName": "",
"id": "da8cd",
"name": "body1",
......@@ -18,13 +18,13 @@
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 290,
"trimY": 84,
"offsetY": 1,
"trimX": 1,
"trimY": 211,
"width": 100,
"height": 100,
"height": 101,
"rawWidth": 100,
"rawHeight": 100,
"rawHeight": 103,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......@@ -43,8 +43,8 @@
"maxPos": []
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"atlasUuid": "8f21f897-8cb9-448d-a674-e0574c83e228"
"imageUuidOrDatabaseUri": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a",
"atlasUuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35"
},
"ver": "1.0.12",
"imported": true,
......@@ -55,7 +55,7 @@
},
"7ca68": {
"importer": "sprite-frame",
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228@7ca68",
"uuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35@7ca68",
"displayName": "",
"id": "7ca68",
"name": "body2",
......@@ -65,12 +65,12 @@
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 392,
"trimY": 84,
"trimX": 1,
"trimY": 1,
"width": 100,
"height": 100,
"height": 103,
"rawWidth": 100,
"rawHeight": 100,
"rawHeight": 103,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......@@ -89,8 +89,8 @@
"maxPos": []
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"atlasUuid": "8f21f897-8cb9-448d-a674-e0574c83e228"
"imageUuidOrDatabaseUri": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a",
"atlasUuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35"
},
"ver": "1.0.12",
"imported": true,
......@@ -101,102 +101,10 @@
},
"9296f": {
"importer": "sprite-frame",
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228@9296f",
"uuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35@9296f",
"displayName": "",
"id": "9296f",
"name": "head",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 125,
"trimY": 1,
"width": 163,
"height": 181,
"rawWidth": 163,
"rawHeight": 181,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [],
"indexes": [],
"uv": [],
"nuv": [],
"minPos": [],
"maxPos": []
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"atlasUuid": "8f21f897-8cb9-448d-a674-e0574c83e228"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"e7dcb": {
"importer": "sprite-frame",
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228@e7dcb",
"displayName": "",
"id": "e7dcb",
"name": "tait1",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 290,
"trimY": 1,
"width": 164,
"height": 81,
"rawWidth": 164,
"rawHeight": 81,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [],
"indexes": [],
"uv": [],
"nuv": [],
"minPos": [],
"maxPos": []
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"atlasUuid": "8f21f897-8cb9-448d-a674-e0574c83e228"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"47d81": {
"importer": "sprite-frame",
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228@47d81",
"displayName": "",
"id": "47d81",
"name": "tait2",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
......@@ -204,11 +112,11 @@
"offsetX": 0,
"offsetY": 0,
"trimX": 1,
"trimY": 1,
"width": 191,
"height": 122,
"rawWidth": 191,
"rawHeight": 122,
"trimY": 106,
"width": 103,
"height": 100,
"rawWidth": 103,
"rawHeight": 100,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......@@ -227,8 +135,8 @@
"maxPos": []
},
"isUuid": true,
"imageUuidOrDatabaseUri": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a",
"atlasUuid": "8f21f897-8cb9-448d-a674-e0574c83e228"
"imageUuidOrDatabaseUri": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a",
"atlasUuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35"
},
"ver": "1.0.12",
"imported": true,
......@@ -239,9 +147,9 @@
}
},
"userData": {
"atlasTextureName": "s0.png",
"atlasTextureName": "default.png",
"format": 3,
"uuid": "8f21f897-8cb9-448d-a674-e0574c83e228",
"textureUuid": "43c3d349-8e95-48ea-bf1a-e9de526864af@6c48a"
"uuid": "89887e9b-e4a4-40bb-9c17-1fd0f88edd35",
"textureUuid": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "89abce21-2213-4c4e-91f5-2769291fd9d1",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a",
"displayName": "default",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "89abce21-2213-4c4e-91f5-2769291fd9d1",
"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": "89abce21-2213-4c4e-91f5-2769291fd9d1@f9941",
"displayName": "default",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 2,
"width": 102,
"height": 309,
"rawWidth": 102,
"rawHeight": 313,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-51,
-154.5,
0,
51,
-154.5,
0,
-51,
154.5,
0,
51,
154.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
311,
102,
311,
0,
2,
102,
2
],
"nuv": [
0,
0.006389776357827476,
1,
0.006389776357827476,
0,
0.9936102236421726,
1,
0.9936102236421726
],
"minPos": [
-51,
-154.5,
0
],
"maxPos": [
51,
154.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "89abce21-2213-4c4e-91f5-2769291fd9d1@6c48a"
}
}
......@@ -2,32 +2,45 @@
import { ccenum } from "cc";
export const Events = {
changeSkinId: "changeSkinId", // 更换皮肤事件
setGameState: "setGameState", // 设置游戏状态事件
showGOver: "showGOver" // 显示游戏结束界面事件
}
changeSkinId: "changeSkinId", // 更换皮肤事件
setGameState: "setGameState", // 设置游戏状态事件
showGOver: "showGOver" // 显示游戏结束界面事件
};
// 食物类型枚举
export enum FoodType {
FOOD = 0, // 普通食物
MONEY = 1 // 金币
FOOD = 0, // 普通食物
MONEY = 1 // 金币
}
ccenum(FoodType)
ccenum(FoodType);
// 移动方向枚举
export enum DirectionType {
DEFAULT = 0, // 默认方向
LEFT = 1, // 向左
RIGHT = 2 // 向右
DEFAULT = 0, // 默认方向
LEFT = 1, // 向左
RIGHT = 2 // 向右
}
// 游戏状态枚举
export enum GameState {
READY = 0, // 准备状态
PLAY = 1, // 游戏中
PAUSE = 2, // 暂停
OVER = 3, // 游戏结束
WIN = 4, // 游戏胜利
QUIT = 5 // 退出游戏
}
\ No newline at end of file
READY = 0, // 准备状态
PLAY = 1, // 游戏中
PAUSE = 2, // 暂停
OVER = 3, // 游戏结束
WIN = 4, // 游戏胜利
QUIT = 5 // 退出游戏
}
export enum FlagType {
SHIELD = 0,
MAGNET = 1,
SPEED_UP = 2,
DOUBLE_SCORE = 3
}
export enum EBodyTag {
Player
}
......@@ -5,7 +5,7 @@ const { ccclass, property } = _decorator;
@ccclass("FastBtn")
export class FastBtn extends Component {
// 是否处于加速状态
isFash: boolean = false;
isFast: boolean = false;
// 按钮精灵组件
@property(Sprite)
......@@ -17,20 +17,20 @@ export class FastBtn extends Component {
onLoad() {
// 注册触摸事件
this.node.on(Node.EventType.TOUCH_START, this.OnTouchStart, this);
this.node.on(Node.EventType.TOUCH_END, this.OnTouchEnd, this);
this.node.on(Node.EventType.TOUCH_CANCEL, this.OnTouchEnd, this);
this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
}
// 按下时的处理
OnTouchStart() {
this.isFash = true;
onTouchStart() {
this.isFast = true;
this.sp.color = this.c1;
}
// 松开时的处理
OnTouchEnd() {
this.isFash = false;
onTouchEnd() {
this.isFast = false;
this.sp.color = this.c2;
}
}
\ No newline at end of file
import { _decorator } from "cc";
import { FlagType } from "./Enums";
const { ccclass } = _decorator;
interface FlagInfo {
type: FlagType;
duration: number; // 持续时间
remainTime: number; // 剩余时间
value: number; // 效果值
}
@ccclass("FlagSystem")
export class FlagSystem {
private flags: Map<FlagType, FlagInfo> = new Map();
// Flag 默认配置
private static readonly DEFAULT_CONFIG: { [key in FlagType]?: { duration: number, value: number } } = {
[FlagType.SHIELD]: { duration: 10, value: 1 }, // 护盾10秒
[FlagType.MAGNET]: { duration: 15, value: 100 }, // 磁铁15秒,吸收范围100
[FlagType.SPEED_UP]: { duration: 8, value: 1.5 }, // 加速8秒,速度1.5倍
[FlagType.DOUBLE_SCORE]: { duration: 12, value: 2 }, // 双倍积分12秒
};
// 添加一个Flag
addFlag(type: FlagType, duration?: number, value?: number) {
const config = FlagSystem.DEFAULT_CONFIG[type];
if (!config) return;
const flagInfo: FlagInfo = {
type,
duration: duration || config.duration,
remainTime: duration || config.duration,
value: value || config.value
};
this.flags.set(type, flagInfo);
}
// 移除一个Flag
removeFlag(type: FlagType) {
this.flags.delete(type);
}
// 检查Flag是否存在且有效
hasFlag(type: FlagType): boolean {
return this.flags.has(type) && this.flags.get(type).remainTime > 0;
}
// 获取Flag的值
getFlagValue(type: FlagType): number {
const flag = this.flags.get(type);
return flag && flag.remainTime > 0 ? flag.value : 0;
}
// 获取Flag的剩余时间
getFlagRemainTime(type: FlagType): number {
const flag = this.flags.get(type);
return flag ? flag.remainTime : 0;
}
// 更新所有Flag状态
update(dt: number) {
this.flags.forEach((flag, type) => {
flag.remainTime -= dt;
if (flag.remainTime <= 0) {
this.flags.delete(type);
}
});
}
// 清除所有Flag
clearAll() {
this.flags.clear();
}
// 获取所有活动的Flag
getActiveFlags(): FlagInfo[] {
return Array.from(this.flags.values()).filter(flag => flag.remainTime > 0);
}
}
\ No newline at end of file
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "c9d3c00d-0519-4dc0-9e9f-103327cfcc08",
"files": [],
"subMetas": {},
"userData": {}
}
This diff is collapsed.
This diff is collapsed.
import { Vec2, Vec3, Size } from "cc";
import { Vec2, Vec3, Size, assetManager, SpriteFrame, SpriteAtlas } from "cc";
/**
* 判断两点是否在指定范围内相交
......@@ -46,4 +46,19 @@ export function formatTime(seconds: number): string {
const mins = Math.floor(seconds / 60);
const secs = Math.floor(seconds % 60);
return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
}
export function loadSkin(skinName: string, bundleName: string = "MainGame"): Promise<SpriteAtlas> {
return new Promise((resolve, reject) => {
assetManager.getBundle(bundleName).load(`skin/${skinName}`, SpriteAtlas,
(err, skin) => {
if (err) {
reject(err);
return;
}
resolve(skin);
}
);
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment