mirror of
https://github.com/ifengzp/cocos-awesome.git
synced 2024-12-25 03:09:19 +00:00
移动残影效果
This commit is contained in:
parent
351cd2b6fe
commit
22f54d7a12
@ -189,7 +189,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
452.93128617926146,
|
443.4050067376326,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -8,7 +8,8 @@ enum sceneList {
|
|||||||
'Magnifying_mirror' = '局部缩放效果',
|
'Magnifying_mirror' = '局部缩放效果',
|
||||||
'Change_clothes' = '换装',
|
'Change_clothes' = '换装',
|
||||||
'Typer' = '打字机效果',
|
'Typer' = '打字机效果',
|
||||||
'Scratch_ticket' = '刮刮卡实现'
|
'Scratch_ticket' = '刮刮卡实现',
|
||||||
|
'Moving_ghost' = '移动残影效果'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
|
7
assets/Scene/Moving_ghost.meta
Normal file
7
assets/Scene/Moving_ghost.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.1",
|
||||||
|
"uuid": "2a7508e7-c0c0-42c3-b200-93f80c022ada",
|
||||||
|
"isSubpackage": false,
|
||||||
|
"subpackageName": "",
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
1111
assets/Scene/Moving_ghost/Moving_ghost.fire
Normal file
1111
assets/Scene/Moving_ghost/Moving_ghost.fire
Normal file
File diff suppressed because it is too large
Load Diff
7
assets/Scene/Moving_ghost/Moving_ghost.fire.meta
Normal file
7
assets/Scene/Moving_ghost/Moving_ghost.fire.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.6",
|
||||||
|
"uuid": "aec53dfe-e702-4258-978a-51e2855d7fac",
|
||||||
|
"asyncLoadAssets": false,
|
||||||
|
"autoReleaseAssets": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
43
assets/Scene/Moving_ghost/Moving_ghost.ts
Normal file
43
assets/Scene/Moving_ghost/Moving_ghost.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
|
@ccclass
|
||||||
|
export default class Moving_ghost extends cc.Component {
|
||||||
|
@property([cc.Sprite])
|
||||||
|
ghostCanvasList: cc.Sprite[] = [];
|
||||||
|
@property(cc.Node)
|
||||||
|
role: cc.Node = null;
|
||||||
|
@property(cc.Camera)
|
||||||
|
roleCamera: cc.Camera = null;
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
const texture = new cc.RenderTexture();
|
||||||
|
texture.initWithSize(this.node.width, this.node.height);
|
||||||
|
const spriteFrame = new cc.SpriteFrame();
|
||||||
|
spriteFrame.setTexture(texture);
|
||||||
|
this.roleCamera.targetTexture = texture;
|
||||||
|
this.ghostCanvasList.forEach((sprite) => {
|
||||||
|
sprite.spriteFrame = spriteFrame;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.schedule(this.ghostFollow, 0.1, cc.macro.REPEAT_FOREVER);
|
||||||
|
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveEvent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
touchMoveEvent(evt: cc.Event.EventTouch) {
|
||||||
|
this.role.x += evt.getDeltaX();
|
||||||
|
this.role.y += evt.getDeltaY();
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
this.unschedule(this.ghostFollow);
|
||||||
|
}
|
||||||
|
|
||||||
|
ghostFollow() {
|
||||||
|
this.ghostCanvasList.forEach((sprite, i) => {
|
||||||
|
const dis = (sprite.node.position as any).sub(this.role.position).mag();
|
||||||
|
if (dis < 0.5) return; // 给个误差范围,涉及到浮点数计算,dis的结果不可能精确为0,小于0.5就可以认为是静止了
|
||||||
|
sprite.node.stopAllActions();
|
||||||
|
sprite.node.runAction(cc.moveTo(i * 0.04 + 0.02, this.role.x, this.role.y));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
9
assets/Scene/Moving_ghost/Moving_ghost.ts.meta
Normal file
9
assets/Scene/Moving_ghost/Moving_ghost.ts.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "0dc97648-cf3b-47ec-824c-0d0c0751e888",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
7
assets/Scene/Moving_ghost/Texture.meta
Normal file
7
assets/Scene/Moving_ghost/Texture.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.1",
|
||||||
|
"uuid": "8435a0d4-52a7-4838-b251-a5d451bb0d8b",
|
||||||
|
"isSubpackage": false,
|
||||||
|
"subpackageName": "",
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
BIN
assets/Scene/Moving_ghost/Texture/sheep.png
Executable file
BIN
assets/Scene/Moving_ghost/Texture/sheep.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
36
assets/Scene/Moving_ghost/Texture/sheep.png.meta
Normal file
36
assets/Scene/Moving_ghost/Texture/sheep.png.meta
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"ver": "2.3.4",
|
||||||
|
"uuid": "eeace92a-7054-4d86-81d2-92898c396ad2",
|
||||||
|
"type": "sprite",
|
||||||
|
"wrapMode": "clamp",
|
||||||
|
"filterMode": "bilinear",
|
||||||
|
"premultiplyAlpha": false,
|
||||||
|
"genMipmaps": false,
|
||||||
|
"packable": true,
|
||||||
|
"width": 228,
|
||||||
|
"height": 159,
|
||||||
|
"platformSettings": {},
|
||||||
|
"subMetas": {
|
||||||
|
"sheep": {
|
||||||
|
"ver": "1.0.4",
|
||||||
|
"uuid": "67109cb1-b42f-4731-ace1-98b0e220760a",
|
||||||
|
"rawTextureUuid": "eeace92a-7054-4d86-81d2-92898c396ad2",
|
||||||
|
"trimType": "auto",
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": -3.5,
|
||||||
|
"offsetY": -0.5,
|
||||||
|
"trimX": 27,
|
||||||
|
"trimY": 24,
|
||||||
|
"width": 167,
|
||||||
|
"height": 112,
|
||||||
|
"rawWidth": 228,
|
||||||
|
"rawHeight": 159,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
assets/Scene/Moving_ghost/Texture/single_color.png
Normal file
BIN
assets/Scene/Moving_ghost/Texture/single_color.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 B |
36
assets/Scene/Moving_ghost/Texture/single_color.png.meta
Normal file
36
assets/Scene/Moving_ghost/Texture/single_color.png.meta
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"ver": "2.3.4",
|
||||||
|
"uuid": "ad64223a-f067-4df0-9d6a-eee10808d220",
|
||||||
|
"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": "de0de72b-78cf-46f2-aa49-1d8c91cabc69",
|
||||||
|
"rawTextureUuid": "ad64223a-f067-4df0-9d6a-eee10808d220",
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
||||||
<title>异名 | cocos-awesome</title>
|
<title>异名 | Cocos Awesome</title>
|
||||||
|
|
||||||
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
||||||
<meta name="viewport"
|
<meta name="viewport"
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
[
|
[
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"excluded-modules": [
|
"excluded-modules": [
|
||||||
@ -15,7 +20,8 @@
|
|||||||
],
|
],
|
||||||
"group-list": [
|
"group-list": [
|
||||||
"default",
|
"default",
|
||||||
"mirror_camera"
|
"mirror_camera",
|
||||||
|
"moving_ghost"
|
||||||
],
|
],
|
||||||
"design-resolution-width": 1334,
|
"design-resolution-width": 1334,
|
||||||
"design-resolution-height": 750,
|
"design-resolution-height": 750,
|
||||||
@ -39,6 +45,5 @@
|
|||||||
"live": {
|
"live": {
|
||||||
"enable": false
|
"enable": false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"start-scene": "current"
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user