Cocos Creator 组件-动作ActionMove

嵌套暂时没法做,先做些常用的单独使用的动作组件

ActionMove.js (拖到需要做该动作的节点上,不同类型的动作互不影响)

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
var ActionDurationMove = cc.Class({
    name: "ActionDurationMove",
    properties: {
        delayTime: {
            default: 0,
            displayName: "延时",
            min: 0
        },
        duration: {
            default: 1,
            displayName: "时长",
            min: 0
        },
        position: {
            default: cc.v2(),
            displayName: "位置",
        },
        callback: {
            default: null,
            type: cc.Component.EventHandler,
            displayName: "完成回调",
        }
    }
});
 
cc.Class({
    extends: cc.Component,
 
    properties: {
        auto: {
            default: false,
            displayName: "自动执行",
            tooltip: "如果false,则需要回调执行该脚本组件的begin方法"
        },
 
        delayTime: {
            default: 0,
            displayName: "自动延迟执行时长",
            tooltip: "只有在自动执行模式下,这个延迟才会有效",
            min: 0
        },
 
        target: {
            default: null,
            type: cc.Node,
            displayName: "执行的节点",
            tooltip: "如果没有设置就默认 挂载该脚本的节点"
        },
 
        startFromCurrent: {
            default: false,
            displayName: "从当前状态执行",
            tooltip: "勾上:从当前状态开始执行动作  不勾:从编辑的初始状态开始执行"
        },
 
        times: {
            default: 1,
            type: cc.Integer,
            displayName: "执行次数",
            tooltip: "一套动作数组 执行的次数",
            min: 1
        },
 
        moveToOrBy: {
            default: true,
            displayName: "移到or移了",
            tooltip: "勾上:移动到(绝对位置);不勾: 移动了(相对位置)"
        },
 
        actionMoves: {
            default: [],
            type: ActionDurationMove,
            displayName: "动作数组",
            tooltip: "暂时只支持到10个,超过了,自己进来扩写代码"
        },
 
        allOverCallback: {
            default: true,
            displayName: "全部完成/每完成一次回调",
            tooltip: "勾上:全部完成才回调  不勾:每完成一次都回调,执行几次就调几遍回调"
        },
 
        overCallbacks: {
            default: [],
            type: cc.Component.EventHandler,
            displayName: "完成回调数组"
        }
    },
 
    // LIFE-CYCLE CALLBACKS:
 
    // onLoad () {},
 
    start () {
        this.actionNode = this.target;
        if (this.actionNode == undefined || this.actionNode == null) {
            this.actionNode = this.node;
        }
 
        this.actionNode.srcPosition = this.actionNode.position;
 
        if (this.auto) {
            this.scheduleOnce(function() {
                this.begin();
            }, this.delayTime);
        }
    },
 
    begin () {
        this.reset();
        this.currentTime = this.times;
        this.action();
    },
 
    reset() {
        this.currentTime = 0;
        this.actionNode.stopActionByTag(111002);
        if (this.startFromCurrent) {
             
        } else {
            this.actionNode.position = this.actionNode.srcPosition;
        }
    },
 
    // update (dt) {},
 
    action () {
        if (this.currentTime > 0) {
            this.currentTime--;
        } else {
            return;
        }
 
        if (this.moveToOrBy) {
            if (this.actionMoves.length == 1) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 2) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 3) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 4) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 5) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 6) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveTo(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 7) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveTo(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveTo(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 8) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveTo(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveTo(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveTo(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 9) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveTo(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveTo(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveTo(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[8].delayTime), cc.moveTo(this.actionMoves[8].duration, this.actionMoves[8].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[8].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 10) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveTo(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveTo(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveTo(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveTo(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveTo(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveTo(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveTo(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveTo(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[8].delayTime), cc.moveTo(this.actionMoves[8].duration, this.actionMoves[8].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[8].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[9].delayTime), cc.moveTo(this.actionMoves[9].duration, this.actionMoves[9].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[9].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            }
        } else {
            if (this.actionMoves.length == 1) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 2) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 3) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 4) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 5) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 6) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveBy(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 7) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveBy(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveBy(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 8) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveBy(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveBy(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveBy(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 9) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveBy(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveBy(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveBy(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[8].delayTime), cc.moveBy(this.actionMoves[8].duration, this.actionMoves[8].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[8].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionMoves.length == 10) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionMoves[0].delayTime), cc.moveBy(this.actionMoves[0].duration, this.actionMoves[0].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[0].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[1].delayTime), cc.moveBy(this.actionMoves[1].duration, this.actionMoves[1].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[1].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[2].delayTime), cc.moveBy(this.actionMoves[2].duration, this.actionMoves[2].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[2].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[3].delayTime), cc.moveBy(this.actionMoves[3].duration, this.actionMoves[3].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[3].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[4].delayTime), cc.moveBy(this.actionMoves[4].duration, this.actionMoves[4].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[4].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[5].delayTime), cc.moveBy(this.actionMoves[5].duration, this.actionMoves[5].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[5].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[6].delayTime), cc.moveBy(this.actionMoves[6].duration, this.actionMoves[6].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[6].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[7].delayTime), cc.moveBy(this.actionMoves[7].duration, this.actionMoves[7].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[7].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[8].delayTime), cc.moveBy(this.actionMoves[8].duration, this.actionMoves[8].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[8].callback); }.bind(this)),
                    cc.delayTime(this.actionMoves[9].delayTime), cc.moveBy(this.actionMoves[9].duration, this.actionMoves[9].position), cc.callFunc(function() { this.callEventHandler(this.actionMoves[9].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            }
        }
 
        this.actionID.setTag(111002);
    },
 
    overCallback() {
        if (this.currentTime > 1) {
            if (this.allOverCallback) {
                for (let i = 0; i < this.overCallbacks.length; i++) {
                    if (this.overCallbacks[i] != null && this.overCallbacks[i].target != null) {
                        this.overCallbacks[i].emit([this, this.overCallbacks[i].customEventData]);
                    }
                }
            }
        } else {
            for (let i = 0; i < this.overCallbacks.length; i++) {
                if (this.overCallbacks[i] != null && this.overCallbacks[i].target != null) {
                    this.overCallbacks[i].emit([this, this.overCallbacks[i].customEventData]);
                }
            }
        }
    },
 
    callEventHandler(eventHandler) {
        if (eventHandler && eventHandler.target) {
            eventHandler.emit([this]);
        }
    }
});

 

posted @   wl小胖  阅读(223)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示