mirror of
https://github.com/ifengzp/cocos-awesome.git
synced 2025-10-09 08:36:03 +00:00
feat: 增加其他场景切换效果
This commit is contained in:
7
assets/Scene/SwitchScene__Strip/Materials.meta
Normal file
7
assets/Scene/SwitchScene__Strip/Materials.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "262f1940-d016-4f77-be84-7327c6b4596b",
|
||||
"isSubpackage": false,
|
||||
"subpackageName": "",
|
||||
"subMetas": {}
|
||||
}
|
22
assets/Scene/SwitchScene__Strip/Materials/strip-lt.mtl
Normal file
22
assets/Scene/SwitchScene__Strip/Materials/strip-lt.mtl
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"__type__": "cc.Material",
|
||||
"_name": "strip-lt",
|
||||
"_objFlags": 0,
|
||||
"_native": "",
|
||||
"_effectAsset": {
|
||||
"__uuid__": "6b233ee2-ef6d-4ee5-9b24-999badfcff68"
|
||||
},
|
||||
"_techniqueIndex": 0,
|
||||
"_techniqueData": {
|
||||
"0": {
|
||||
"props": {
|
||||
"direction": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": -1,
|
||||
"y": 1
|
||||
}
|
||||
},
|
||||
"defines": {}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.3",
|
||||
"uuid": "ee73e8c0-5ff0-486a-bcdf-dec85b04755b",
|
||||
"dataAsSubAsset": null,
|
||||
"subMetas": {}
|
||||
}
|
140
assets/Scene/SwitchScene__Strip/Materials/strip.effect
Normal file
140
assets/Scene/SwitchScene__Strip/Materials/strip.effect
Normal file
@@ -0,0 +1,140 @@
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
CCEffect %{
|
||||
techniques:
|
||||
- passes:
|
||||
- vert: vs
|
||||
frag: fs
|
||||
blendState:
|
||||
targets:
|
||||
- blend: true
|
||||
rasterizerState:
|
||||
cullMode: none
|
||||
properties:
|
||||
texture: { value: white }
|
||||
texture2: { value: white }
|
||||
time: { value: 0 }
|
||||
direction: { value: [1, 1]}
|
||||
}%
|
||||
|
||||
CCProgram transition %{
|
||||
|
||||
// https://www.shadertoy.com/view/ls3cDB
|
||||
|
||||
const float PI = 3.141592653589793;
|
||||
const float PI_2 = 3.141592653589793;
|
||||
|
||||
#define radius .1
|
||||
|
||||
uniform Transition {
|
||||
vec2 direction; // = [1, 1]
|
||||
};
|
||||
|
||||
float aspect = 1.;//screenSize.x / screenSize.y;
|
||||
|
||||
vec4 iMouse = vec4(
|
||||
screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),
|
||||
screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),
|
||||
screenSize.x * (1.0 - step(0.0, direction.x)),
|
||||
screenSize.y * (1.0 - step(0.0, direction.y))
|
||||
);
|
||||
|
||||
|
||||
vec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;
|
||||
vec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);
|
||||
|
||||
vec4 transition(vec2 uv) {
|
||||
// vec2 uv = fragCoord * vec2(aspect, 1.) / screenSize.xy;
|
||||
|
||||
float dist = dot(uv - mouse, mouseDir);
|
||||
vec2 linePoint = uv - dist * mouseDir;
|
||||
|
||||
vec4 fragColor = vec4(1.0);
|
||||
if (dist > radius) {
|
||||
fragColor = texture(texture2, uv);
|
||||
// add shadow
|
||||
// fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
|
||||
}
|
||||
else if (dist >= 0.) {
|
||||
// map to cylinder point
|
||||
float theta = asin(dist / radius);
|
||||
vec2 p2 = linePoint + mouseDir * (PI - theta) * radius;
|
||||
vec2 p1 = linePoint + mouseDir * theta * radius;
|
||||
uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;
|
||||
fragColor = texture(texture, uv);
|
||||
fragColor.rgb *= pow(clamp((radius - dist) / radius, 0., 1.), .2);
|
||||
}
|
||||
else {
|
||||
vec2 p = linePoint + mouseDir * (abs(dist) + PI * radius);
|
||||
uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;
|
||||
fragColor = texture(texture, uv);
|
||||
}
|
||||
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
}%
|
||||
|
||||
CCProgram vs %{
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include <cc-global>
|
||||
#include <cc-local>
|
||||
|
||||
in vec3 a_position;
|
||||
in lowp vec4 a_color;
|
||||
|
||||
in mediump vec2 a_uv0;
|
||||
out mediump vec2 v_uv0;
|
||||
|
||||
out lowp vec4 v_color;
|
||||
|
||||
uniform Time {
|
||||
vec2 screenSize;
|
||||
float time;
|
||||
};
|
||||
|
||||
void main() {
|
||||
mat4 mvp;
|
||||
|
||||
mvp = cc_matViewProj;
|
||||
|
||||
v_uv0 = a_uv0;
|
||||
v_color = a_color;
|
||||
|
||||
gl_Position = mvp * vec4(a_position, 1);
|
||||
}
|
||||
|
||||
}%
|
||||
|
||||
CCProgram fs %{
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D texture2;
|
||||
in mediump vec2 v_uv0;
|
||||
|
||||
uniform Time {
|
||||
vec2 screenSize;
|
||||
float time;
|
||||
};
|
||||
|
||||
in lowp vec4 v_color;
|
||||
|
||||
vec4 getFromColor(vec2 uv) {
|
||||
return texture(texture, uv);
|
||||
}
|
||||
|
||||
vec4 getToColor(vec2 uv) {
|
||||
return texture(texture2, uv);
|
||||
}
|
||||
|
||||
#include <transition>
|
||||
|
||||
void main () {
|
||||
gl_FragColor = v_color * transition(v_uv0);
|
||||
}
|
||||
|
||||
}%
|
17
assets/Scene/SwitchScene__Strip/Materials/strip.effect.meta
Normal file
17
assets/Scene/SwitchScene__Strip/Materials/strip.effect.meta
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"ver": "1.0.25",
|
||||
"uuid": "6b233ee2-ef6d-4ee5-9b24-999badfcff68",
|
||||
"compiledShaders": [
|
||||
{
|
||||
"glsl1": {
|
||||
"vert": "\nprecision highp float;\nuniform mediump mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute lowp vec4 a_color;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nvarying lowp vec4 v_color;\nvoid main() {\n mat4 mvp;\n mvp = cc_matViewProj;\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\n}",
|
||||
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nvarying mediump vec2 v_uv0;\nuniform vec2 screenSize;\nuniform float time;\nvarying lowp vec4 v_color;\nconst float PI = 3.141592653589793;\nconst float PI_2 = 3.141592653589793;\nuniform vec2 direction;\nfloat aspect = 1.;\nvec4 iMouse = vec4(\n screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),\n screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),\n screenSize.x * (1.0 - step(0.0, direction.x)),\n screenSize.y * (1.0 - step(0.0, direction.y))\n);\nvec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;\nvec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);\nvec4 transition(vec2 uv) {\n float dist = dot(uv - mouse, mouseDir);\n vec2 linePoint = uv - dist * mouseDir;\n vec4 fragColor = vec4(1.0);\n if (dist > .1) {\n fragColor = texture2D(texture2, uv);\n }\n else if (dist >= 0.) {\n float theta = asin(dist / .1);\n vec2 p2 = linePoint + mouseDir * (PI - theta) * .1;\n vec2 p1 = linePoint + mouseDir * theta * .1;\n uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;\n fragColor = texture2D(texture, uv);\n fragColor.rgb *= pow(clamp((.1 - dist) / .1, 0., 1.), .2);\n }\n else {\n vec2 p = linePoint + mouseDir * (abs(dist) + PI * .1);\n uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;\n fragColor = texture2D(texture, uv);\n }\n return fragColor;\n}\nvoid main () {\n gl_FragColor = v_color * transition(v_uv0);\n}"
|
||||
},
|
||||
"glsl3": {
|
||||
"vert": "\nprecision highp float;\nuniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_nativeSize;\n highp mat4 cc_matView;\n mediump mat4 cc_matViewInv;\n mediump mat4 cc_matProj;\n mediump mat4 cc_matProjInv;\n mediump mat4 cc_matViewProj;\n mediump mat4 cc_matViewProjInv;\n mediump vec4 cc_cameraPos;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin lowp vec4 a_color;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nout lowp vec4 v_color;\nuniform Time {\n vec2 screenSize;\n float time;\n};\nvoid main() {\n mat4 mvp;\n mvp = cc_matViewProj;\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\n}",
|
||||
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nin mediump vec2 v_uv0;\nuniform Time {\n vec2 screenSize;\n float time;\n};\nin lowp vec4 v_color;\nconst float PI = 3.141592653589793;\nconst float PI_2 = 3.141592653589793;\nuniform Transition {\n vec2 direction;\n};\nfloat aspect = 1.;\nvec4 iMouse = vec4(\n screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),\n screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),\n screenSize.x * (1.0 - step(0.0, direction.x)),\n screenSize.y * (1.0 - step(0.0, direction.y))\n);\nvec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;\nvec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);\nvec4 transition(vec2 uv) {\n float dist = dot(uv - mouse, mouseDir);\n vec2 linePoint = uv - dist * mouseDir;\n vec4 fragColor = vec4(1.0);\n if (dist > .1) {\n fragColor = texture(texture2, uv);\n }\n else if (dist >= 0.) {\n float theta = asin(dist / .1);\n vec2 p2 = linePoint + mouseDir * (PI - theta) * .1;\n vec2 p1 = linePoint + mouseDir * theta * .1;\n uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;\n fragColor = texture(texture, uv);\n fragColor.rgb *= pow(clamp((.1 - dist) / .1, 0., 1.), .2);\n }\n else {\n vec2 p = linePoint + mouseDir * (abs(dist) + PI * .1);\n uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;\n fragColor = texture(texture, uv);\n }\n return fragColor;\n}\nvoid main () {\n gl_FragColor = v_color * transition(v_uv0);\n}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
740
assets/Scene/SwitchScene__Strip/SwitchScene__Strip.fire
Normal file
740
assets/Scene/SwitchScene__Strip/SwitchScene__Strip.fire
Normal file
@@ -0,0 +1,740 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_native": "",
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 13
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_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": "17ca8f16-26d6-4862-90da-cb338d55f704"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 512,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_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": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_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.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__": "22c8cP1MQNB7Ka1h8g/gS0z",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"separator": {
|
||||
"__id__": 8
|
||||
},
|
||||
"spriteFrame1": {
|
||||
"__uuid__": "fadd364e-5cc6-4fe1-a458-93dc172c36af"
|
||||
},
|
||||
"spriteFrame2": {
|
||||
"__uuid__": "24e8b90f-3d1d-4078-90fa-567b5d3a78a8"
|
||||
},
|
||||
"bgSprite": {
|
||||
"__id__": 10
|
||||
},
|
||||
"material": {
|
||||
"__uuid__": "ee73e8c0-5ff0-486a-bcdf-dec85b04755b"
|
||||
},
|
||||
"_id": "02KUZjxDBPoIDETyoLgMk8"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Separator",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 171,
|
||||
"b": 23,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 10,
|
||||
"height": 750
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
333,
|
||||
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": "00zwOFnw9A9Y2jJcAfpxGt"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "bfovdQprtLZrbQA9328iTr"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "b70P96s8FD1LitaZ7aobMA"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Bg",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_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": "34YKVYdF5MoYlFN+Zfb6wk"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_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": 1024,
|
||||
"_originalHeight": 445,
|
||||
"_id": "711M5JfuBPs5F7P5bDVb/1"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Btn",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 14
|
||||
},
|
||||
{
|
||||
"__id__": 16
|
||||
},
|
||||
{
|
||||
"__id__": 17
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 1477,
|
||||
"height": 118
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
667,
|
||||
528.7,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0.7,
|
||||
0.7,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "bcVNNAEfFEJL7tftaCUB7n"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Button",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 13
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 15
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_N$pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"a": 255
|
||||
},
|
||||
"pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"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": 124,
|
||||
"g": 124,
|
||||
"b": 124,
|
||||
"a": 255
|
||||
},
|
||||
"_N$normalSprite": null,
|
||||
"_N$pressedSprite": null,
|
||||
"pressedSprite": null,
|
||||
"_N$hoverSprite": null,
|
||||
"hoverSprite": null,
|
||||
"_N$disabledSprite": null,
|
||||
"_N$target": {
|
||||
"__id__": 13
|
||||
},
|
||||
"_id": "fdJg28i7pE6pi4D1ovRRp0"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ClickEvent",
|
||||
"target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"component": "",
|
||||
"_componentId": "22c8cP1MQNB7Ka1h8g/gS0z",
|
||||
"handler": "switchSceneByTransition",
|
||||
"customEventData": "6"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 13
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "86714285-13db-44f6-86aa-11838e0d4831"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "c1sR5klVZHraEr68/UTkLE"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 13
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 17,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 180,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 157.942,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 0,
|
||||
"_originalHeight": 0,
|
||||
"_id": "a6rm0uXY9DlbNNnoWq9hN0"
|
||||
}
|
||||
]
|
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.2.6",
|
||||
"uuid": "17ca8f16-26d6-4862-90da-cb338d55f704",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
89
assets/Scene/SwitchScene__Strip/SwitchScene__Strip.ts
Normal file
89
assets/Scene/SwitchScene__Strip/SwitchScene__Strip.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class SwitchScene extends cc.Component {
|
||||
@property(cc.Node) separator = null;
|
||||
|
||||
@property(cc.SpriteFrame) spriteFrame1 = null;
|
||||
@property(cc.SpriteFrame) spriteFrame2 = null;
|
||||
@property(cc.Sprite) bgSprite = null;
|
||||
@property(cc.Material) material = null;
|
||||
private _spriteMaterial: cc.Material;
|
||||
|
||||
touchStartPos = cc.Vec2.ZERO;
|
||||
separatorStartPos = cc.Vec2.ZERO;
|
||||
|
||||
start() {
|
||||
this.bgSprite.spriteFrame.setTexture(this.spriteFrame1._texture);
|
||||
this.initSpriteMaterial();
|
||||
this.playTransitionAnimation();
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.separatorStartPos = this.separator.getPosition();
|
||||
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
}
|
||||
|
||||
switchSceneByTransition(event, value) {
|
||||
cc.director.emit('setBackBtnVisibility', false);
|
||||
cc.director.emit('switchSceneByTransition', value);
|
||||
}
|
||||
|
||||
playTransitionAnimation() {
|
||||
let progress = 0;
|
||||
let targetProgress = cc.winSize.width;
|
||||
let totalTime = 3;
|
||||
let startTime = Date.now();
|
||||
|
||||
const loop = () => {
|
||||
if (!this._spriteMaterial || !this.touchStartPos) return;
|
||||
if (!this.touchStartPos.equals(cc.Vec2.ZERO)) return;
|
||||
|
||||
let currentTime = Date.now();
|
||||
let elapsedTime = (currentTime - startTime) / 1000;
|
||||
let _progress = (elapsedTime / totalTime) * targetProgress;
|
||||
progress = Math.min(_progress, targetProgress);
|
||||
|
||||
this._spriteMaterial.setProperty('time', progress / cc.winSize.width);
|
||||
this.separator.setPosition({ x: progress, y: 0 });
|
||||
|
||||
if (progress < targetProgress) {
|
||||
requestAnimationFrame(loop.bind(this));
|
||||
}
|
||||
};
|
||||
loop();
|
||||
}
|
||||
|
||||
onTouchStart(event) {
|
||||
this.separatorStartPos = this.separator.getPosition();
|
||||
this.touchStartPos = this.node.convertToNodeSpaceAR(event.getLocation());
|
||||
}
|
||||
|
||||
private onTouchMove(event) {
|
||||
// 获取当前触摸点的位置
|
||||
let touchPos = this.node.convertToNodeSpaceAR(event.getLocation());
|
||||
// 计算触摸点相对于起始位置的偏移量
|
||||
let offset = touchPos.sub(this.touchStartPos);
|
||||
let targetPos = this.separatorStartPos.add(offset);
|
||||
let targetX = Math.max(0, Math.min(targetPos.x, cc.winSize.width));
|
||||
this.separator.setPosition({
|
||||
x: targetX,
|
||||
y: 0
|
||||
});
|
||||
this._spriteMaterial.setProperty('time', targetX / cc.winSize.width);
|
||||
}
|
||||
|
||||
initSpriteMaterial() {
|
||||
let newMaterial = cc.MaterialVariant.create(this.material, this.bgSprite);
|
||||
newMaterial.setProperty('texture', this.spriteFrame1._texture);
|
||||
newMaterial.setProperty('texture2', this.spriteFrame2._texture);
|
||||
newMaterial.setProperty('screenSize', new Float32Array([cc.winSize.width, cc.winSize.height]));
|
||||
newMaterial.setProperty('time', 0.25);
|
||||
|
||||
this.spriteFrame1._texture.setFlipY(true);
|
||||
this.spriteFrame2._texture.setFlipY(true);
|
||||
this.bgSprite.setMaterial(0, newMaterial);
|
||||
this._spriteMaterial = newMaterial;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "22c8c3f5-3103-41ec-a6b5-87c83f812d33",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
7
assets/Scene/SwitchScene__Strip/Texture.meta
Normal file
7
assets/Scene/SwitchScene__Strip/Texture.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "d13769a9-caa5-4374-8f1b-926afb820254",
|
||||
"isSubpackage": false,
|
||||
"subpackageName": "",
|
||||
"subMetas": {}
|
||||
}
|
BIN
assets/Scene/SwitchScene__Strip/Texture/bg1.jpeg
Normal file
BIN
assets/Scene/SwitchScene__Strip/Texture/bg1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 208 KiB |
36
assets/Scene/SwitchScene__Strip/Texture/bg1.jpeg.meta
Normal file
36
assets/Scene/SwitchScene__Strip/Texture/bg1.jpeg.meta
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"ver": "2.3.4",
|
||||
"uuid": "9038deed-cca8-46ff-9027-551eddadd35c",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"width": 1600,
|
||||
"height": 1200,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"bg1": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "fadd364e-5cc6-4fe1-a458-93dc172c36af",
|
||||
"rawTextureUuid": "9038deed-cca8-46ff-9027-551eddadd35c",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 1600,
|
||||
"height": 1200,
|
||||
"rawWidth": 1600,
|
||||
"rawHeight": 1200,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
BIN
assets/Scene/SwitchScene__Strip/Texture/bg2.jpeg
Normal file
BIN
assets/Scene/SwitchScene__Strip/Texture/bg2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 KiB |
36
assets/Scene/SwitchScene__Strip/Texture/bg2.jpeg.meta
Normal file
36
assets/Scene/SwitchScene__Strip/Texture/bg2.jpeg.meta
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"ver": "2.3.4",
|
||||
"uuid": "c3bc747f-2cef-4c27-911d-37cb1f4ca5f2",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"width": 1600,
|
||||
"height": 1200,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"bg2": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "24e8b90f-3d1d-4078-90fa-567b5d3a78a8",
|
||||
"rawTextureUuid": "c3bc747f-2cef-4c27-911d-37cb1f4ca5f2",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 1600,
|
||||
"height": 1200,
|
||||
"rawWidth": 1600,
|
||||
"rawHeight": 1200,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
BIN
assets/Scene/SwitchScene__Strip/Texture/btn.png
Normal file
BIN
assets/Scene/SwitchScene__Strip/Texture/btn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
36
assets/Scene/SwitchScene__Strip/Texture/btn.png.meta
Normal file
36
assets/Scene/SwitchScene__Strip/Texture/btn.png.meta
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"ver": "2.3.4",
|
||||
"uuid": "a73c17f0-79b7-4480-a172-508c49264fd8",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"width": 1477,
|
||||
"height": 118,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"btn": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "8068bba9-2f44-4980-911c-2dd9bae35a9c",
|
||||
"rawTextureUuid": "a73c17f0-79b7-4480-a172-508c49264fd8",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 1477,
|
||||
"height": 118,
|
||||
"rawWidth": 1477,
|
||||
"rawHeight": 118,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user