diff --git a/assets/Scene/Home/Home.ts b/assets/Scene/Home/Home.ts index eb52617..874bebc 100644 --- a/assets/Scene/Home/Home.ts +++ b/assets/Scene/Home/Home.ts @@ -7,7 +7,8 @@ enum sceneList { 'Coin_fly_to_wallet' = '金币落袋效果', 'Magnifying_mirror' = '局部缩放效果', 'Change_clothes' = '换装', - 'Typer' = '打字机效果' + 'Typer' = '打字机效果', + 'Scratch_ticket' = '刮刮卡实现' } @ccclass diff --git a/assets/Scene/Scratch_ticket.meta b/assets/Scene/Scratch_ticket.meta new file mode 100644 index 0000000..d62c50e --- /dev/null +++ b/assets/Scene/Scratch_ticket.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "92256264-46a3-4594-8512-abd2123e644b", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Scratch_ticket.fire b/assets/Scene/Scratch_ticket/Scratch_ticket.fire new file mode 100644 index 0000000..ad470f1 --- /dev/null +++ b/assets/Scene/Scratch_ticket/Scratch_ticket.fire @@ -0,0 +1,1288 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "e613032d-7fc6-420f-bc64-a57e756187c0" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 16 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ + { + "__id__": 26 + }, + { + "__id__": 27 + }, + { + "__id__": 28 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 667, + 375, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a5esZu+45LA5mBpvttspPD" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 452.93128617926146, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e1WoFrQ79G7r4ZuQE3HlNb" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "81GN3uXINKVLeW4+iKSlim" + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 27, + "g": 38, + "b": 46, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "50a9IgSZpCdooWYk/SpKEz" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "6f431892-2e43-49d9-a9c9-3d7cf91ae2e9" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "6e3RoP20hGVJV8OcjRv8Gs" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 2, + "_originalHeight": 2, + "_id": "4dNmUEdY9Cs7fgGP6vhyXo" + }, + { + "__type__": "cc.Node", + "_name": "scratch_ticket", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 675, + "height": 477 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 42, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c2AKSB/jBK0JDgqLu8yWJM" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "007d56b3-d617-41fa-aec8-020894559897" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "a2ZIwpTdFG5aIIWu3l5BOt" + }, + { + "__type__": "cc.Node", + "_name": "ticket", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 486, + "height": 234 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "70Up6KtLNEF4V7NUexOOBZ" + }, + { + "__type__": "cc.Node", + "_name": "ticket_mask", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "2efkwYloVEeqDj9TL48p5L" + }, + { + "__type__": "cc.Node", + "_name": "maks_pic", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 204, + "g": 204, + "b": 204, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 486, + "height": 234 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "96u7QuBL9Eo4QBbPcVVAzv" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "3947437a-6f46-41e0-926c-270f7cd145c8" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "08UA5tWIVGvrAQu8DAGoVr" + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_spriteFrame": null, + "_type": 0, + "_segments": 64, + "_N$alphaThreshold": 0.1, + "_N$inverted": true, + "_id": "9eTvWkvZFOq4fDw2SLjsem" + }, + { + "__type__": "cc.Graphics", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "6f801092-0c37-4f30-89ef-c8d960825b36" + } + ], + "_lineWidth": 1, + "_strokeColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_lineJoin": 2, + "_lineCap": 0, + "_fillColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_miterLimit": 10, + "_id": "a7LUI9bsREQZg3sav7x9tZ" + }, + { + "__type__": "cc.Node", + "_name": "progerss", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": null, + "_opacity": 149, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 134.46, + "height": 25.2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -145.626, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "36+YWa3hVM9Jw5j4N90aqf" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "已经刮开了 0%", + "_N$string": "已经刮开了 0%", + "_fontSize": 20, + "_lineHeight": 20, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "5eCnoCWIRNh7vBc8zt+gTc" + }, + { + "__type__": "cc.Node", + "_name": "button", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 19 + } + ], + "_active": true, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -274.91, + 0, + 0, + 0, + 0, + 1, + 1.5, + 1.5, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "45bYGQqohFbLrrKl2/Ouuk" + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 18 + }, + "_children": [ + { + "__id__": 20 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 23 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9eNaJzSO9BLaYaI3brGW/D" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 19 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "92hnOK9/9PSoCnYeLHJbm0" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "重置", + "_N$string": "重置", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "43GqR1w6xNIIHzX0XGExHD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "01NrzByNRICIuMml8migxZ" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 40, + "_id": "9cHQbGWUhIfqHRAToj2Xzk" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 18 + }, + "_enabled": true, + "_normalMaterial": { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + }, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 25 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 2, + "transition": 2, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 230, + "g": 230, + "b": 230, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 200, + "g": 200, + "b": 200, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 120, + "g": 120, + "b": 120, + "a": 200 + }, + "_N$normalSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 19 + }, + "_id": "3fRqmMtpNHDITkQBlp8vCC" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "", + "_componentId": "d30e1f08DZOMI5wufTMlpN5", + "handler": "reset", + "customEventData": "" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1334, + "height": 750 + }, + "_fitWidth": false, + "_fitHeight": true, + "_id": "59Cd0ovbdF4byw5sbjJDx7" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 1, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "29zXboiXFBKoIV4PQ2liTe" + }, + { + "__type__": "d30e1f08DZOMI5wufTMlpN5", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "maskNode": { + "__id__": 11 + }, + "ticketNode": { + "__id__": 10 + }, + "progerss": { + "__id__": 17 + }, + "_id": "c58Nb809lHjY65XXlH3x9b" + } +] \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Scratch_ticket.fire.meta b/assets/Scene/Scratch_ticket/Scratch_ticket.fire.meta new file mode 100644 index 0000000..ec316a1 --- /dev/null +++ b/assets/Scene/Scratch_ticket/Scratch_ticket.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.6", + "uuid": "e613032d-7fc6-420f-bc64-a57e756187c0", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Scratch_ticket.ts b/assets/Scene/Scratch_ticket/Scratch_ticket.ts new file mode 100644 index 0000000..72207ed --- /dev/null +++ b/assets/Scene/Scratch_ticket/Scratch_ticket.ts @@ -0,0 +1,120 @@ +const { ccclass, property } = cc._decorator; +const CALC_RECT_WIDTH = 40; +const CLEAR_LINE_WIDTH = 40; + +@ccclass +export default class Scratch_ticket extends cc.Component { + @property(cc.Node) + maskNode: cc.Node = null; + @property(cc.Node) + ticketNode: cc.Node = null; + @property(cc.Label) + progerss: cc.Label = null; + + onLoad() { + this.reset(); + this.ticketNode.on(cc.Node.EventType.TOUCH_START, this.touchStartEvent, this); + this.ticketNode.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveEvent, this); + this.ticketNode.on(cc.Node.EventType.TOUCH_END, this.touchEndEvent, this); + this.ticketNode.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndEvent, this); + } + + beforeDestroy() { + this.ticketNode.off(cc.Node.EventType.TOUCH_START, this.touchStartEvent, this); + this.ticketNode.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveEvent, this); + this.ticketNode.on(cc.Node.EventType.TOUCH_END, this.touchEndEvent, this); + this.ticketNode.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndEvent, this); + } + + touchStartEvent(event) { + let point = this.ticketNode.convertToNodeSpaceAR(event.getLocation()); + this.clearMask(point); + } + + touchMoveEvent(event) { + let point = this.ticketNode.convertToNodeSpaceAR(event.getLocation()); + this.clearMask(point); + } + + touchEndEvent() { + this.tempDrawPoints = []; + this.calcProgress(); + } + + calcDebugger: boolean = false; // 辅助开关,开启则会绘制划开涂层所属的小格子 + calcProgress() { + let hitItemCount = 0; + let ctx = this.ticketNode.getComponent(cc.Graphics); + this.polygonPointsList.forEach((item) => { + if (!item.isHit) return; + hitItemCount += 1; + + if (!this.calcDebugger) return; + ctx.rect(item.rect.x, item.rect.y, item.rect.width, item.rect.height); + ctx.fillColor = cc.color(216, 18, 18, 255); + ctx.fill(); + }); + + this.progerss.string = `已经刮开了 ${Math.ceil((hitItemCount / this.polygonPointsList.length) * 100)}%`; + } + + tempDrawPoints: cc.Vec2[] = []; + clearMask(pos) { + let mask: any = this.maskNode.getComponent(cc.Mask); + let stencil = mask._graphics; + const len = this.tempDrawPoints.length; + this.tempDrawPoints.push(pos); + + if (len <= 1) { + // 只有一个点,用圆来清除涂层 + stencil.circle(pos.x, pos.y, CLEAR_LINE_WIDTH / 2); + stencil.fill(); + + // 记录点所在的格子 + this.polygonPointsList.forEach((item) => { + if (item.isHit) return; + const xFlag = pos.x > item.rect.x && pos.x < item.rect.x + item.rect.width; + const yFlag = pos.y > item.rect.y && pos.y < item.rect.y + item.rect.height; + if (xFlag && yFlag) item.isHit = true; + }); + } else { + // 存在多个点,用线段来清除涂层 + let prevPos = this.tempDrawPoints[len - 2]; + let curPos = this.tempDrawPoints[len - 1]; + + stencil.moveTo(prevPos.x, prevPos.y); + stencil.lineTo(curPos.x, curPos.y); + stencil.lineWidth = CLEAR_LINE_WIDTH; + stencil.lineCap = cc.Graphics.LineCap.ROUND; + stencil.lineJoin = cc.Graphics.LineJoin.ROUND; + stencil.strokeColor = cc.color(255, 255, 255, 255); + stencil.stroke(); + + // 记录线段经过的格子 + this.polygonPointsList.forEach((item) => { + item.isHit = item.isHit || cc.Intersection.lineRect(prevPos, curPos, item.rect); + }); + } + } + + polygonPointsList: { rect: cc.Rect; isHit: boolean }[] = []; + reset() { + let mask: any = this.maskNode.getComponent(cc.Mask); + mask._graphics.clear(); + + this.tempDrawPoints = []; + this.polygonPointsList = []; + this.progerss.string = '已经刮开了 0%'; + this.ticketNode.getComponent(cc.Graphics).clear(); + + // 生成小格子,用来辅助统计涂层的刮开比例 + for (let x = 0; x < this.ticketNode.width; x += CALC_RECT_WIDTH) { + for (let y = 0; y < this.ticketNode.height; y += CALC_RECT_WIDTH) { + this.polygonPointsList.push({ + rect: cc.rect(x - this.ticketNode.width / 2, y - this.ticketNode.height / 2, CALC_RECT_WIDTH, CALC_RECT_WIDTH), + isHit: false + }); + } + } + } +} diff --git a/assets/Scene/Scratch_ticket/Scratch_ticket.ts.meta b/assets/Scene/Scratch_ticket/Scratch_ticket.ts.meta new file mode 100644 index 0000000..8bc8fe1 --- /dev/null +++ b/assets/Scene/Scratch_ticket/Scratch_ticket.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "d30e17f4-f036-4e30-8e70-b9f4cc969379", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Texture.meta b/assets/Scene/Scratch_ticket/Texture.meta new file mode 100644 index 0000000..156e1be --- /dev/null +++ b/assets/Scene/Scratch_ticket/Texture.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "19698126-b55a-4d28-97a7-1d2bd93feee6", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png b/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png new file mode 100644 index 0000000..8f661f2 Binary files /dev/null and b/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png differ diff --git a/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png.meta b/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png.meta new file mode 100644 index 0000000..00e30cd --- /dev/null +++ b/assets/Scene/Scratch_ticket/Texture/scratch_ticket.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "9db9d60f-857e-4c9b-89ea-45725dfc3dc8", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 676, + "height": 478, + "platformSettings": {}, + "subMetas": { + "scratch_ticket": { + "ver": "1.0.4", + "uuid": "007d56b3-d617-41fa-aec8-020894559897", + "rawTextureUuid": "9db9d60f-857e-4c9b-89ea-45725dfc3dc8", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": -0.5, + "offsetY": -0.5, + "trimX": 0, + "trimY": 1, + "width": 675, + "height": 477, + "rawWidth": 676, + "rawHeight": 478, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Texture/single_color.png b/assets/Scene/Scratch_ticket/Texture/single_color.png new file mode 100644 index 0000000..fa6376e Binary files /dev/null and b/assets/Scene/Scratch_ticket/Texture/single_color.png differ diff --git a/assets/Scene/Scratch_ticket/Texture/single_color.png.meta b/assets/Scene/Scratch_ticket/Texture/single_color.png.meta new file mode 100644 index 0000000..8d8cf29 --- /dev/null +++ b/assets/Scene/Scratch_ticket/Texture/single_color.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "6e930562-0cce-4912-afa6-6e711eaed38c", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 2, + "height": 2, + "platformSettings": {}, + "subMetas": { + "single_color": { + "ver": "1.0.4", + "uuid": "6f431892-2e43-49d9-a9c9-3d7cf91ae2e9", + "rawTextureUuid": "6e930562-0cce-4912-afa6-6e711eaed38c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2, + "height": 2, + "rawWidth": 2, + "rawHeight": 2, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/assets/Scene/Scratch_ticket/Texture/ticket_mask.png b/assets/Scene/Scratch_ticket/Texture/ticket_mask.png new file mode 100644 index 0000000..4f34d31 Binary files /dev/null and b/assets/Scene/Scratch_ticket/Texture/ticket_mask.png differ diff --git a/assets/Scene/Scratch_ticket/Texture/ticket_mask.png.meta b/assets/Scene/Scratch_ticket/Texture/ticket_mask.png.meta new file mode 100644 index 0000000..63ba03d --- /dev/null +++ b/assets/Scene/Scratch_ticket/Texture/ticket_mask.png.meta @@ -0,0 +1,36 @@ +{ + "ver": "2.3.4", + "uuid": "9a8148c8-a077-4c5d-9bd6-0b3d14e9a339", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "width": 486, + "height": 234, + "platformSettings": {}, + "subMetas": { + "ticket_mask": { + "ver": "1.0.4", + "uuid": "3947437a-6f46-41e0-926c-270f7cd145c8", + "rawTextureUuid": "9a8148c8-a077-4c5d-9bd6-0b3d14e9a339", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 486, + "height": 234, + "rawWidth": 486, + "rawHeight": 234, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file