86510959-3ac0-4227-95f8-b94c622ad69b.js
5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"use strict";
cc._RF.push(module, '86510lZOsBCJ5X4uUxiKtab', 'SurroundMotionStreakAction');
// script/game/ui/SurroundMotionStreakAction.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const { ccclass, property } = cc._decorator;
var MoveDirection;
(function (MoveDirection) {
MoveDirection[MoveDirection["Clockwise"] = 0] = "Clockwise";
MoveDirection[MoveDirection["Anticlockwise"] = 1] = "Anticlockwise";
})(MoveDirection || (MoveDirection = {}));
let SurroundMotionStreakAction = /** @class */ (() => {
let SurroundMotionStreakAction = class SurroundMotionStreakAction extends cc.Component {
constructor() {
// LIFE-CYCLE CALLBACKS:
super(...arguments);
this.moveSpeed = 1;
this.fadeTime = 1;
this.minSeg = 1;
this.stroke = 10;
this.direction = MoveDirection.Clockwise;
this.actNode = new cc.Node;
this.motionStreakTexture = new cc.Texture2D;
this._baseTime = 1;
}
onLoad() { }
start() {
}
onEnable() {
let lt = cc.v2(this.node.width * (-1) / 2, this.node.height / 2);
let rt = cc.v2(this.node.width / 2, this.node.height / 2);
let rb = cc.v2(this.node.width / 2, this.node.height * (-1) / 2);
let lb = cc.v2(this.node.width * (-1) / 2, this.node.height * (-1) / 2);
let actTime = this._baseTime / this.moveSpeed;
let max = Math.max(this.node.width, this.node.height);
let wTime = this.node.width / max * actTime;
let hTime = this.node.height / max * actTime;
let ltAct = cc.moveTo(hTime, lt);
let rtAct = cc.moveTo(wTime, rt);
let rbAct = cc.moveTo(hTime, rb);
let lbAct = cc.moveTo(wTime, lb);
if (this.direction === MoveDirection.Anticlockwise) {
ltAct = cc.moveTo(wTime, lt);
rtAct = cc.moveTo(hTime, rt);
rbAct = cc.moveTo(wTime, rb);
lbAct = cc.moveTo(hTime, lb);
}
let seqClockwise = cc.sequence(ltAct, rtAct, rbAct, lbAct);
let seqAnticlockwise = cc.sequence(rtAct, ltAct, lbAct, rbAct);
let motionStreak = this.actNode.getComponent(cc.MotionStreak);
if (!motionStreak) {
motionStreak = this.actNode.addComponent(cc.MotionStreak);
motionStreak.texture = this.motionStreakTexture;
motionStreak.fadeTime = this.fadeTime;
motionStreak.minSeg = this.minSeg;
motionStreak.stroke = this.stroke;
}
motionStreak.enabled = true;
this.actNode.stopAllActions();
if (this.direction === MoveDirection.Clockwise) {
this.actNode.x = this.node.width * (-1) / 2;
this.actNode.y = this.node.height / 2;
this.actNode.runAction(cc.repeatForever(seqClockwise));
}
else if (this.direction === MoveDirection.Anticlockwise) {
this.actNode.x = this.node.width / 2;
this.actNode.y = this.node.height / 2;
this.actNode.runAction(cc.repeatForever(seqAnticlockwise));
}
}
onDisable() {
let motionStreak = this.actNode.getComponent(cc.MotionStreak);
if (motionStreak) {
motionStreak.enabled = false;
}
this.node.stopAllActions();
}
};
__decorate([
property
], SurroundMotionStreakAction.prototype, "moveSpeed", void 0);
__decorate([
property
], SurroundMotionStreakAction.prototype, "fadeTime", void 0);
__decorate([
property
], SurroundMotionStreakAction.prototype, "minSeg", void 0);
__decorate([
property
], SurroundMotionStreakAction.prototype, "stroke", void 0);
__decorate([
property
], SurroundMotionStreakAction.prototype, "direction", void 0);
__decorate([
property({ type: cc.Node })
], SurroundMotionStreakAction.prototype, "actNode", void 0);
__decorate([
property({ type: cc.Texture2D })
], SurroundMotionStreakAction.prototype, "motionStreakTexture", void 0);
SurroundMotionStreakAction = __decorate([
ccclass
], SurroundMotionStreakAction);
return SurroundMotionStreakAction;
})();
exports.default = SurroundMotionStreakAction;
cc._RF.pop();