Commit 97992bb6 authored by haiyoucuv's avatar haiyoucuv

init

parent 1cb804ce
......@@ -23,7 +23,7 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 9
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
......@@ -54,7 +54,7 @@
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 10
"__id__": 14
},
"_id": "53947ca7-3484-4b53-800d-509405063d68"
},
......@@ -69,21 +69,24 @@
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 5
"__id__": 9
},
{
"__id__": 6
"__id__": 10
},
{
"__id__": 7
"__id__": 11
},
{
"__id__": 8
"__id__": 12
}
],
"_prefab": null,
......@@ -207,6 +210,135 @@
"_trackingType": 0,
"_id": "18n70u7WZCw5lXnvt5XF12"
},
{
"__type__": "cc.Node",
"_name": "Snake",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "ee8O/qSSVCI71mLCUiPZ14"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "f4NXIEHRxHb42L3h6JeOws"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "57520716-48c8-4a19-8acf-41c9f8777fb0@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "26Y28dKY5DYrbelc1SN0/x"
},
{
"__type__": "5c1d7QKgk1JsaoI0kPfkdM9",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"nodePrefab": {
"__uuid__": "a9574a8f-f883-4d7f-99ca-86c3984b98aa",
"__expectedType__": "cc.Prefab"
},
"gap": 20,
"_id": "5fBUl8qiFBzbPmQ/o4D604"
},
{
"__type__": "cc.UITransform",
"_name": "",
......@@ -286,6 +418,10 @@
"_enabled": true,
"__prefab": null,
"uiLayer": null,
"snake": {
"__id__": 5
},
"speed": 200,
"_id": "82BvT1r7xD+JbBxZ+0VBoD"
},
{
......@@ -299,28 +435,28 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 11
"__id__": 15
},
"shadows": {
"__id__": 12
"__id__": 16
},
"_skybox": {
"__id__": 13
"__id__": 17
},
"fog": {
"__id__": 14
"__id__": 18
},
"octree": {
"__id__": 15
"__id__": 19
},
"skin": {
"__id__": 16
"__id__": 20
},
"lightProbeInfo": {
"__id__": 17
"__id__": 21
},
"postSettings": {
"__id__": 18
"__id__": 22
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false
......
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "9f26dd88-76e6-43a9-aa25-2610da607d68",
"files": [],
"subMetas": {},
"userData": {}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "5cd68bd9-12b8-4f3a-8561-6f04bee36fab",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "5cd68bd9-12b8-4f3a-8561-6f04bee36fab@6c48a",
"displayName": "1",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "5cd68bd9-12b8-4f3a-8561-6f04bee36fab",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "5cd68bd9-12b8-4f3a-8561-6f04bee36fab@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "ddac7794-c7a4-48c5-af61-9b423244cd56",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "ddac7794-c7a4-48c5-af61-9b423244cd56@6c48a",
"displayName": "2",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "ddac7794-c7a4-48c5-af61-9b423244cd56",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "ddac7794-c7a4-48c5-af61-9b423244cd56@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "e2d279b1-9efa-4892-9fda-ec634890607a",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "e2d279b1-9efa-4892-9fda-ec634890607a@6c48a",
"displayName": "3",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "e2d279b1-9efa-4892-9fda-ec634890607a",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "e2d279b1-9efa-4892-9fda-ec634890607a@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "5f469da0-8050-49f7-b1ee-f0c22b0d417c",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "5f469da0-8050-49f7-b1ee-f0c22b0d417c@6c48a",
"displayName": "4",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "5f469da0-8050-49f7-b1ee-f0c22b0d417c",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "5f469da0-8050-49f7-b1ee-f0c22b0d417c@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "ce62197d-60bb-42b0-9956-41a4dd6d8f02",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "ce62197d-60bb-42b0-9956-41a4dd6d8f02@6c48a",
"displayName": "5",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "ce62197d-60bb-42b0-9956-41a4dd6d8f02",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "ce62197d-60bb-42b0-9956-41a4dd6d8f02@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "69e69ee3-3317-4297-ba6d-9e4689622de0",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "69e69ee3-3317-4297-ba6d-9e4689622de0@6c48a",
"displayName": "6",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "69e69ee3-3317-4297-ba6d-9e4689622de0",
"isUuid": true,
"visible": false,
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "69e69ee3-3317-4297-ba6d-9e4689622de0@6c48a",
"flipVertical": false
}
}
{
"ver": "1.0.1",
"importer": "ttf-font",
"imported": true,
"uuid": "94fd4aeb-6850-44cc-8dd6-72d39fc549ff",
"files": [
".json",
"AlibabaPuHuiTi-3-85-Bold.ttf"
],
"subMetas": {},
"userData": {}
}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "c8f66d17-351a-48da-a12c-0212d28575c4",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{
"USE_INSTANCING": true
},
{},
{},
{},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"emissive": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
}
},
{},
{},
{},
{},
{}
]
}
\ No newline at end of file
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "6e2fa11c-2468-446a-a6b9-d05f534a596a",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "c8f66d17-351a-48da-a12c-0212d28575c4",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{
"USE_INSTANCING": true
},
{},
{},
{},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"roughness": 1,
"specularIntensity": 0
},
{},
{},
{},
{},
{}
]
}
\ No newline at end of file
{"ver":"1.0.21","importer":"material","imported":true,"uuid":"32924590-b9c6-42cf-9693-0181a173ad4e","files":[".json"],"subMetas":{},"userData":{}}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "c8f66d17-351a-48da-a12c-0212d28575c4",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{
"USE_INSTANCING": true
},
{},
{},
{},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"roughness": 1,
"specularIntensity": 0,
"emissive": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"emissiveScale": {
"__type__": "cc.Vec3",
"x": 0.025,
"y": 0.025,
"z": 0.025
}
},
{},
{},
{},
{},
{}
]
}
\ No newline at end of file
{"ver":"1.0.21","importer":"material","imported":true,"uuid":"70aede3c-4375-42c6-abc9-54a869f7adba","files":[".json"],"subMetas":{},"userData":{}}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{
"USE_INSTANCING": true,
"USE_TEXTURE": true
},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "5cd68bd9-12b8-4f3a-8561-6f04bee36fab@6c48a",
"__expectedType__": "cc.Texture2D"
}
},
{},
{}
]
}
\ No newline at end of file
{"ver":"1.0.21","importer":"material","imported":true,"uuid":"ef4024d6-1023-4544-8a14-3fe0ab7bb522","files":[".json"],"subMetas":{},"userData":{}}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "971bdb23-3ff6-43eb-b422-1c30165a3663",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "ee83d89f-eac7-491a-8660-50e779854fe0@6c48a",
"__expectedType__": "cc.Texture2D"
}
}
]
}
\ No newline at end of file
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "fc737222-9e11-400a-8119-f513d5820f83",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "971bdb23-3ff6-43eb-b422-1c30165a3663",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": "0",
"_defines": [
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "39e1e9d6-b461-4c06-81b9-f1ddc09193d7@6c48a",
"__expectedType__": "cc.Texture2D"
}
},
{}
]
}
\ No newline at end of file
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "fc4593aa-cae7-447c-8316-f92f0c7590d4",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- name: opaque
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
properties: &props
mainTexture: { value: grey }
particleTexture: { value: grey }
tilingOffset: { value: [1, 1, 0, 0] }
mainColor: { value: [1, 1, 1, 1], linear: true, editor: { type: color } }
colorScale: { value: [1, 1, 1], target: colorScaleAndCutoff.xyz }
alphaThreshold: { value: 0.5, target: colorScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
color: { target: mainColor, linear: true, editor: { visible: false } } # backward compability
migrations: &migs
properties:
mainColor: { formerlySerializedAs: color }
- &planar-shadow
vert: planar-shadow-vs:vert
frag: planar-shadow-fs:frag
phase: planar-shadow
propertyIndex: 0
depthStencilState:
depthTest: true
depthWrite: false
stencilTestFront: true
stencilFuncFront: not_equal
stencilPassOpFront: replace
stencilRef: 0x80 # only use the leftmost bit
stencilReadMask: 0x80
stencilWriteMask: 0x80
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
- &deferred-forward
vert: unlit-vs:vert
frag: unlit-fs:frag
phase: deferred-forward
propertyIndex: 0
- name: transparent
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
depthStencilState: &d1
depthTest: true
depthWrite: false
blendState: &b1
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
- *planar-shadow
- &deferred-forward-transparent
vert: unlit-vs:vert
frag: unlit-fs:frag
phase: deferred-forward
propertyIndex: 0
migrations: *migs
depthStencilState: *d1
blendState: *b1
- name: add
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: &r1 { cullMode: none }
depthStencilState: *d1
blendState: &b2
targets:
- blend: true
blendSrc: src_alpha
blendDst: one
blendSrcAlpha: src_alpha
blendDstAlpha: one
properties: *props
migrations: *migs
- &deferred-forward-add
vert: unlit-vs:vert
frag: unlit-fs:frag
phase: deferred-forward
rasterizerState: *r1
depthStencilState: *d1
blendState: *b2
propertyIndex: 0
migrations: *migs
- name: alpha-blend
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: *r1
depthStencilState: *d1
blendState: &b3
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
- &deferred-forward-alpha-blend
vert: unlit-vs:vert
frag: unlit-fs:frag
phase: deferred-forward
rasterizerState: *r1
depthStencilState: *d1
blendState: *b3
propertyIndex: 0
migrations: *migs
}%
CCProgram unlit-vs %{
precision highp float;
#include <legacy/input>
#include <builtin/uniforms/cc-global>
#include <legacy/decode-base>
#include <legacy/local-batch>
#include <legacy/input>
#include <legacy/fog-vs>
#if USE_VERTEX_COLOR
in lowp vec4 a_color;
out lowp vec4 v_color;
#endif
#if USE_TEXTURE
out vec2 v_uv;
uniform TexCoords {
vec4 tilingOffset;
};
#endif
vec4 vert () {
vec4 position;
CCVertInput(position);
mat4 matWorld;
CCGetWorldMatrix(matWorld);
#if USE_TEXTURE
v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;
#if SAMPLE_FROM_RT
CC_HANDLE_RT_SAMPLE_FLIP(v_uv);
#endif
#endif
#if USE_VERTEX_COLOR
v_color = a_color;
#endif
CC_TRANSFER_FOG(matWorld * position);
return cc_matProj * (cc_matView * matWorld) * position;
}
}%
CCProgram unlit-fs %{
precision highp float;
#include <legacy/output-standard>
#include <legacy/fog-fs>
#include <builtin/uniforms/cc-global>
#if USE_ALPHA_TEST
#pragma define-meta ALPHA_TEST_CHANNEL options([a, r, g, b])
#endif
#if USE_TEXTURE
in vec2 v_uv;
uniform sampler2D mainTexture;
uniform sampler2D particleTexture;
#endif
uniform Constant {
vec4 mainColor;
vec4 colorScaleAndCutoff;
};
#if USE_VERTEX_COLOR
in lowp vec4 v_color;
#endif
vec4 frag () {
vec4 o = mainColor;
o.rgb *= colorScaleAndCutoff.xyz;
#if USE_VERTEX_COLOR
o.rgb *= SRGBToLinear(v_color.rgb);//use linear
o.a *= v_color.a;
#endif
#if USE_TEXTURE
vec4 texColor = texture(mainTexture, v_uv);
vec2 uv = v_uv;
uv.y += cc_time.x / 4.0;
vec4 particleColor = texture(particleTexture, uv);
texColor += particleColor;
texColor.rgb = SRGBToLinear(texColor.rgb);
o *= texColor;
#endif
#if USE_ALPHA_TEST
if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;
#endif
CC_APPLY_FOG(o);
return CCFragOutput(o);
}
}%
CCProgram planar-shadow-vs %{
precision highp float;
#include <legacy/input>
#include <builtin/uniforms/cc-global>
#include <legacy/decode-base>
#include <legacy/local-batch>
#include <builtin/uniforms/cc-shadow>
#include <common/lighting/functions>
out float v_dist;
vec4 vert () {
vec4 position;
CCVertInput(position);
// World Space
mat4 matWorld, matWorldIT;
CCGetWorldMatrixFull(matWorld, matWorldIT);
vec3 worldPos = (matWorld * position).xyz;
vec4 shadowPos = CalculatePlanarShadowPos(worldPos, cc_cameraPos.xyz, cc_mainLitDir.xyz, cc_planarNDInfo);
position = CalculatePlanarShadowClipPos(shadowPos, cc_cameraPos.xyz, cc_matView, cc_matProj, cc_nearFar, cc_shadowWHPBInfo.w);
v_dist = shadowPos.w;
return position;
}
}%
CCProgram planar-shadow-fs %{
precision highp float;
#include <builtin/uniforms/cc-shadow>
#include <legacy/output>
in float v_dist;
vec4 frag () {
if(v_dist < 0.0)
discard;
return CCFragOutput(cc_shadowColor);
}
}%
{
"ver": "1.7.1",
"importer": "effect",
"imported": true,
"uuid": "2da8908c-0cfa-42b9-a096-d2a8c3077dfe",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "2da8908c-0cfa-42b9-a096-d2a8c3077dfe",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 2,
"_defines": [
{
"USE_INSTANCING": true,
"USE_TEXTURE": true
},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "f6df98d9-6a78-4b37-819c-b85c91dd9046@6c48a",
"__expectedType__": "cc.Texture2D"
},
"particleTexture": {
"__uuid__": "27625008-7534-479b-be2b-3266f5eb51ef@6c48a",
"__expectedType__": "cc.Texture2D"
}
},
{}
]
}
\ No newline at end of file
{"ver":"1.0.21","importer":"material","imported":true,"uuid":"3c0aedbc-593b-4d89-9145-0714810d35d5","files":[".json"],"subMetas":{},"userData":{}}
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 2,
"_defines": [
{
"USE_INSTANCING": true,
"USE_TEXTURE": true
},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "c5420122-73de-4379-bb8d-6e4fc74b14e1@6c48a",
"__expectedType__": "cc.Texture2D"
}
},
{}
]
}
\ No newline at end of file
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "9518c0cb-641d-4f31-8e82-5da4ae3d507c",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
[
{
"__type__": "cc.Prefab",
"_name": "光幕",
"_name": "SnakeNode",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
......@@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "光幕",
"_name": "SnakeNode",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
......@@ -24,14 +24,11 @@
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 7
"__id__": 4
}
],
"_prefab": {
"__id__": 9
"__id__": 6
},
"_lpos": {
"__type__": "cc.Vec3",
......@@ -49,11 +46,11 @@
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 4,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
......@@ -63,68 +60,7 @@
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "Quad<ModelComponent>",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_materials": [
{
"__uuid__": "3c0aedbc-593b-4d89-9145-0714810d35d5",
"__expectedType__": "cc.Material"
}
],
"_visFlags": 0,
"bakeSettings": {
"__id__": 4
},
"_mesh": {
"__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@fc873",
"__expectedType__": "cc.Mesh"
},
"_shadowCastingMode": 0,
"_shadowReceivingMode": 1,
"_shadowBias": 0,
"_shadowNormalBias": 0,
"_reflectionProbeId": -1,
"_reflectionProbeBlendId": -1,
"_reflectionProbeBlendWeight": 0,
"_enabledGlobalStandardSkinObject": false,
"_enableMorph": true,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1esW4ppkxLe5XPsWE+qAlV"
},
{
"__type__": "cc.ModelBakeSettings",
"texture": null,
"uvParam": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_bakeable": false,
"_castShadow": false,
"_receiveShadow": false,
"_recieveShadow": false,
"_lightmapSize": 64,
"_useLightProbe": false,
"_bakeToLightProbe": true,
"_reflectionProbeType": 0,
"_bakeToReflectionProbe": true
},
{
"__type__": "cc.RigidBody",
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
......@@ -133,35 +69,26 @@
},
"_enabled": true,
"__prefab": {
"__id__": 6
"__id__": 3
},
"_group": 16,
"_type": 2,
"_mass": 1,
"_allowSleep": true,
"_linearDamping": 0.1,
"_angularDamping": 0.1,
"_useGravity": true,
"_linearFactor": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_angularFactor": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "adOM9abJ9K9r9tHOQOdFB/"
"fileId": "24/bLKmKpBEoSXWDCvfHXU"
},
{
"__type__": "cc.BoxCollider",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
......@@ -170,27 +97,40 @@
},
"_enabled": true,
"__prefab": {
"__id__": 8
},
"_material": null,
"_isTrigger": true,
"_center": {
"__type__": "cc.Vec3",
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "57520716-48c8-4a19-8acf-41c9f8777fb0@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
"z": -0.25
},
"_size": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 0.5
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7foxUj5fJFh6p76ymjuNPN"
"fileId": "c40RCLyqZAIpd1vxqhFvj8"
},
{
"__type__": "cc.PrefabInfo",
......@@ -200,7 +140,7 @@
"asset": {
"__id__": 0
},
"fileId": "51Y9gslglDXYKIJMxhL9pl",
"fileId": "8963j3RWtPLZvQEDLda/Eu",
"targetOverrides": null
}
]
\ No newline at end of file
......@@ -2,12 +2,12 @@
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "ff249ea2-131c-46cc-8bb5-e07bfcca3d01",
"uuid": "a9574a8f-f883-4d7f-99ca-86c3984b98aa",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Wall"
"syncNodeName": "SnakeNode"
}
}
This diff is collapsed.
This diff is collapsed.
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "50650cb7-af92-4041-93d7-e8d9a7fa446d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Wall2"
}
}
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "9f30d580-4fa7-48b4-af7f-460d23e3c9e0",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "光幕"
}
}
[
{
"__type__": "cc.Prefab",
"_name": "圆环",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "圆环",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 7
}
],
"_prefab": {
"__id__": 9
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "Quad<ModelComponent>",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_materials": [
{
"__uuid__": "9518c0cb-641d-4f31-8e82-5da4ae3d507c",
"__expectedType__": "cc.Material"
}
],
"_visFlags": 0,
"bakeSettings": {
"__id__": 4
},
"_mesh": {
"__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@fc873",
"__expectedType__": "cc.Mesh"
},
"_shadowCastingMode": 0,
"_shadowReceivingMode": 1,
"_shadowBias": 0,
"_shadowNormalBias": 0,
"_reflectionProbeId": -1,
"_reflectionProbeBlendId": -1,
"_reflectionProbeBlendWeight": 0,
"_enabledGlobalStandardSkinObject": false,
"_enableMorph": true,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "03EPHmR75GcYq5CJ8OJb6h"
},
{
"__type__": "cc.ModelBakeSettings",
"texture": null,
"uvParam": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_bakeable": false,
"_castShadow": false,
"_receiveShadow": false,
"_recieveShadow": false,
"_lightmapSize": 64,
"_useLightProbe": false,
"_bakeToLightProbe": true,
"_reflectionProbeType": 0,
"_bakeToReflectionProbe": true
},
{
"__type__": "cc.RigidBody",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_group": 16,
"_type": 2,
"_mass": 1,
"_allowSleep": true,
"_linearDamping": 0.1,
"_angularDamping": 0.1,
"_useGravity": true,
"_linearFactor": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_angularFactor": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "44yph2cU1NXYAQITb6YGON"
},
{
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 8
},
"_material": null,
"_isTrigger": true,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": -0.125
},
"_size": {
"__type__": "cc.Vec3",
"x": 0.74,
"y": 0.74,
"z": 0.25
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7fsrR045pJHIRSu7DpqTQ5"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "40QKTBsKxLooiCP4/ZePDg",
"instance": null,
"targetOverrides": null
}
]
\ No newline at end of file
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "92797147-1d66-471c-a539-78bceda0ebaf",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "圆环"
}
}
This diff is collapsed.
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "92ecb835-f55d-479d-88a7-89cdca3a7dd6",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "破碎"
}
}
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "9e1763c8-e82d-4301-801a-d738b026a7af",
"files": [],
"subMetas": {},
"userData": {}
}
{
"ver": "1.0.0",
"importer": "*",
"imported": true,
"uuid": "46343c99-7acb-4df4-9c35-3d9cab5e102e",
"files": [
".json",
".svga"
],
"subMetas": {},
"userData": {}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "c5420122-73de-4379-bb8d-6e4fc74b14e1",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "c5420122-73de-4379-bb8d-6e4fc74b14e1@6c48a",
"displayName": "圆环",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "c5420122-73de-4379-bb8d-6e4fc74b14e1",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "nearest",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "c5420122-73de-4379-bb8d-6e4fc74b14e1@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "f6df98d9-6a78-4b37-819c-b85c91dd9046",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "f6df98d9-6a78-4b37-819c-b85c91dd9046@6c48a",
"displayName": "玻璃框",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "f6df98d9-6a78-4b37-819c-b85c91dd9046",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "nearest",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "f6df98d9-6a78-4b37-819c-b85c91dd9046@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "27625008-7534-479b-be2b-3266f5eb51ef",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "27625008-7534-479b-be2b-3266f5eb51ef@6c48a",
"displayName": "玻璃花纹",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"imageUuidOrDatabaseUri": "27625008-7534-479b-be2b-3266f5eb51ef",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "nearest",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "texture",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "27625008-7534-479b-be2b-3266f5eb51ef@6c48a"
}
}
import { _decorator, Component, Material, MeshRenderer, Node, v4 } from 'cc';
const {ccclass, property} = _decorator;
@ccclass('Bg')
export class Bg extends Component {
@property({type: Node}) camera: Node = null;
@property({type: Node}) player: Node = null;
initZ = 0;
material: Material = null;
onLoad() {
this.initZ = this.node.position.z;
this.material = this.getComponent(MeshRenderer).material;
}
start() {
}
update(dt: number) {
this.camera.position && this.node.setPosition(0, -this.camera.position.y, this.initZ);
this.player.position && this.material.setProperty(
'tilingOffset',
v4(1, 1, -this.player.position.z / 50, 0)
);
}
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "b3c83fb4-26f5-41ab-aa02-4cd58d23142f",
"files": [],
"subMetas": {},
"userData": {}
}
import { _decorator, Color, Texture2D } from "cc";
const {ccclass, property} = _decorator;
@ccclass(`BgAndColor`)
export class BgAndColor {
@property({type: Texture2D})
bg: Texture2D = null;
@property({type: Color})
color: Color = Color.clone(Color.WHITE);
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "3668e9cb-8b9f-4204-bf35-01f754872754",
"files": [],
"subMetas": {},
"userData": {}
}
import { _decorator, Input, input, } from "cc";
import { _decorator, EventKeyboard, Input, input, KeyCode, Node, } from "cc";
import Scene from "db://assets/Module/Scene";
import { Snake } from "./Snake";
const { ccclass, property } = _decorator;
export enum DIR {
UP,
DOWN,
LEFT,
RIGHT,
}
@ccclass("MainGame")
export class MainGame extends Scene {
static bundle: string = "MainGame";
static skin: string = "MainGame";
onLoad() {
@property(Node)
snake: Node = null;
}
@property
speed: number = 200;
async start() {
onLoad() {
input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
input.on(Input.EventType.TOUCH_END, this.onTouchEnd, this);
input.on(Input.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this);
input.on(Input.EventType.KEY_UP, this.onKeyUp, this);
}
curDir: DIR = DIR.UP;
keyArr = [];
async start() {
this.schedule(() => {
this.snake.getComponent(Snake).addNode();
}, 1);
}
onDestroy() {
input.off(Input.EventType.TOUCH_START, this.onTouchStart, this);
input.off(Input.EventType.TOUCH_END, this.onTouchEnd, this);
input.off(Input.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
input.off(Input.EventType.KEY_DOWN, this.onKeyDown, this);
input.off(Input.EventType.KEY_UP, this.onKeyUp, this);
}
onKeyDown(event: EventKeyboard) {
const keyArr = [
KeyCode.KEY_W,
KeyCode.KEY_S,
KeyCode.KEY_A,
KeyCode.KEY_D,
];
if (keyArr.indexOf(event.keyCode) > -1) {
this.keyArr.push(event.keyCode);
}
this.setDir();
}
onKeyUp(event: EventKeyboard) {
const index = this.keyArr.indexOf(event.keyCode);
if (index > -1) {
this.keyArr.splice(index, 1);
}
this.setDir();
}
setDir() {
if (!this.keyArr.length) return;
this.curDir = {
[KeyCode.KEY_W]: DIR.UP,
[KeyCode.KEY_S]: DIR.DOWN,
[KeyCode.KEY_A]: DIR.LEFT,
[KeyCode.KEY_D]: DIR.RIGHT,
}[this.keyArr[this.keyArr.length - 1]];
}
onTouchStart(event: any) {
......@@ -37,6 +97,19 @@ export class MainGame extends Scene {
update(dt: number) {
if (this.curDir == DIR.UP) {
const newY = this.snake.position.y + this.speed * dt;
this.snake.setPosition(this.snake.position.x, newY);
} else if (this.curDir == DIR.DOWN) {
const newY = this.snake.position.y - this.speed * dt;
this.snake.setPosition(this.snake.position.x, newY);
} else if (this.curDir == DIR.LEFT) {
const newX = this.snake.position.x - this.speed * dt;
this.snake.setPosition(newX, this.snake.position.y);
} else if (this.curDir == DIR.RIGHT) {
const newX = this.snake.position.x + this.speed * dt;
this.snake.setPosition(newX, this.snake.position.y);
}
}
......
import { _decorator, Component, instantiate, Node, Prefab, Vec3 } from "cc";
const { ccclass, property } = _decorator;
class SnakeNode {
node: Node = null;
next: SnakeNode = null;
}
const _tempPos = new Vec3();
const _tempPrePos = new Vec3();
@ccclass("Snake")
export class Snake extends Component {
@property(Prefab)
nodePrefab: Prefab = null;
@property
gap: number = 50;
head: SnakeNode = null;
last: SnakeNode = null;
onLoad() {
this.last = this.head = new SnakeNode();
this.head.node = this.node;
}
addNode() {
const node = instantiate(this.nodePrefab);
this.node.parent.addChild(node);
node.position = this.last.node.position;
const snakeNode = new SnakeNode();
snakeNode.node = node;
this.last.next = snakeNode;
this.last = snakeNode;
}
update(dt: number) {
let pre: SnakeNode = this.head;
let current: SnakeNode = this.head.next;
while (current) {
const posDir = current.node.getPosition(_tempPos)
.subtract(pre.node.position)
.normalize();
const pos = pre.node.getPosition(_tempPrePos)
.add(posDir.multiplyScalar(this.gap));
current.node.setPosition(pos);
pre = current;
current = current.next;
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ed495fb3-0fdf-4afd-a68e-7d2a1ead383c",
"uuid": "5c1d740a-824d-49b1-aa08-d243df91d33d",
"files": [],
"subMetas": {},
"userData": {}
......
import { _decorator, Component, instantiate, lerp, Node, Prefab } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('Wall')
export class Wall extends Component {
@property(Node) top: Node = null;
@property(Node) bottom: Node = null;
@property isInit = false;
@property(Prefab) lightPrefab: Prefab = null;
@property(Prefab) ringPrefab: Prefab = null;
dH: number = 1;
onLoad() {
if (!this.isInit) {
this.reset();
}
}
get topY() {
return this.top.position.y + this.node.position.y;
}
reset() {
this.dH = Math.random() * 3 + 2;
this.top.setPosition(0, this.dH / 2, 0);
this.bottom.setPosition(0, -this.dH / 2, 0);
this.light?.destroy();
this.ring?.destroy();
}
resetGuide() {
this.dH = Math.random() * 0.5 + 4.5;
this.top.setPosition(0, this.dH / 2, 0);
this.bottom.setPosition(0, -this.dH / 2, 0);
}
resetDeath() {
this.dH = Math.random() * 3 + 0.5;
this.top.setPosition(0, this.dH / 2, 0);
this.bottom.setPosition(0, -this.dH / 2, 0);
}
light: Node = null;
createLight() {
this.light = instantiate(this.lightPrefab);
this.node.addChild(this.light);
this.light.setScale(1, this.dH, 1);
}
ring: Node = null;
createRing(scale = lerp(this.dH * 0.4, this.dH * 0.75, Math.random())) {
this.ring = instantiate(this.ringPrefab);
this.node.addChild(this.ring);
this.ring.setScale(scale, scale);
const dyHalf = (this.dH - scale) / 2;
const y = lerp(-dyHalf, dyHalf, Math.random());
this.ring.setPosition(0, y);
}
}
......@@ -40,7 +40,7 @@
},
"physics": {
"_value": false,
"_option": "physics-physx"
"_option": "physics-builtin"
},
"physics-ammo": {
"_value": "physics-ammo"
......@@ -52,7 +52,7 @@
"_value": "physics-physx"
},
"physics-builtin": {
"_value": false
"_value": "physics-builtin"
},
"physics-2d": {
"_value": true,
......
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