移动残影效果

This commit is contained in:
ifengzp 2020-04-06 02:35:34 +08:00
parent 351cd2b6fe
commit 22f54d7a12
14 changed files with 1268 additions and 6 deletions

View File

@ -189,7 +189,7 @@
"array": [
0,
0,
452.93128617926146,
443.4050067376326,
0,
0,
0,

View File

@ -8,7 +8,8 @@ enum sceneList {
'Magnifying_mirror' = '局部缩放效果',
'Change_clothes' = '换装',
'Typer' = '打字机效果',
'Scratch_ticket' = '刮刮卡实现'
'Scratch_ticket' = '刮刮卡实现',
'Moving_ghost' = '移动残影效果'
}
@ccclass

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "2a7508e7-c0c0-42c3-b200-93f80c022ada",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
{
"ver": "1.2.6",
"uuid": "aec53dfe-e702-4258-978a-51e2855d7fac",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View 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));
});
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "0dc97648-cf3b-47ec-824c-0d0c0751e888",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "8435a0d4-52a7-4838-b251-a5d451bb0d8b",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View 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": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View 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": {}
}
}
}

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>异名 | cocos-awesome</title>
<title>异名 | Cocos Awesome</title>
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
<meta name="viewport"

View File

@ -6,6 +6,11 @@
[
false,
false
],
[
false,
false,
false
]
],
"excluded-modules": [
@ -15,7 +20,8 @@
],
"group-list": [
"default",
"mirror_camera"
"mirror_camera",
"moving_ghost"
],
"design-resolution-width": 1334,
"design-resolution-height": 750,
@ -39,6 +45,5 @@
"live": {
"enable": false
}
},
"start-scene": "current"
}
}