forked from cocos/cocos-example-dark-slash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
creator.d.ts
8145 lines (7789 loc) · 299 KB
/
creator.d.ts
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace */
declare module cc {
/** Init Debug setting.
*/
export function _initDebugSetting(mode : DebugMode) : void;
/** Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
- In Cocos Creator, error is red.
- In Chrome, error have a red icon along with red message text.
@param obj A JavaScript string containing zero or more substitution strings.
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
export function error(obj : any, subst : any) : void;
/** Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
- In Cocos Creator, warning is yellow.
- In Chrome, warning have a yellow warning icon with the message text.
@param obj A JavaScript string containing zero or more substitution strings.
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
export function warn(obj : any, subst : any) : void;
/** Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
@param obj A JavaScript string containing zero or more substitution strings.
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
export function log(obj : any, subst : any) : void;
/** Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
- In Cocos Creator, info is blue.
- In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
@param obj A JavaScript string containing zero or more substitution strings.
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
export function info(obj : any, subst : any) : void;
/** Gets the current running speed. <br />
Will get a percentage number, compared to the original speed.
*/
export function getSpeed() : number;
/** alter the speed of the inner function in runtime.
*/
export function setSpeed(speed : number) : void;
/** initializes the action.
*/
export function initWithAction(action : ActionInterval, speed : number) : boolean;
/** Set inner Action.
*/
export function setInnerAction(action : ActionInterval) : void;
/** Get inner Action.
*/
export function getInnerAction() : ActionInterval;
/** Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
or less (speed < 1) time. <br/>
Useful to simulate 'slow motion' or 'fast forward' effect.
*/
export function speed(action : ActionInterval, speed : number) : Action;
/** Create a follow action which makes its target follows another node.
@example
```js
// example
// creates the action with a set boundary
var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
node.runAction(followAction);
// creates the action with no boundary set
var followAction = cc.follow(targetNode);
node.runAction(followAction);
```
*/
export function follow(followedNode : Node, rect : Rect) : Action;
/** creates an action with a Cardinal Spline array of points and tension.
@param points array of control points
@example
```js
//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);
```
*/
export function cardinalSplineTo(duration : number, points : any[], tension : number) : ActionInterval;
/** creates an action with a Cardinal Spline array of points and tension.
*/
export function cardinalSplineBy(duration : number, points : any[], tension : number) : ActionInterval;
/** creates an action with a Cardinal Spline array of points and tension.
@example
```js
var action1 = cc.catmullRomTo(3, array);
```
*/
export function catmullRomTo(dt : number, points : any[]) : ActionInterval;
/** Creates an action with a Cardinal Spline array of points and tension
@example
```js
var action1 = cc.catmullRomBy(3, array);
```
*/
export function catmullRomBy(dt : number, points : any[]) : ActionInterval;
/** Creates the action easing object with the rate parameter. <br />
From slow to fast.
@example
```js
// example
action.easing(cc.easeIn(3.0));
```
*/
export function easeIn(rate : number) : any;
/** Creates the action easing object with the rate parameter. <br />
From fast to slow.
@example
```js
// example
action.easing(cc.easeOut(3.0));
```
*/
export function easeOut(rate : number) : any;
/** Creates the action easing object with the rate parameter. <br />
Slow to fast then to slow.
@example
```js
//The new usage
action.easing(cc.easeInOut(3.0));
```
*/
export function easeInOut(rate : number) : any;
/** Creates the action easing object with the rate parameter. <br />
Reference easeInExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeExponentialIn());
```
*/
export function easeExponentialIn() : any;
/** creates the action easing object. <br />
Reference easeOutExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeExponentialOut());
```
*/
export function easeExponentialOut() : any;
/** creates an EaseExponentialInOut action easing object. <br />
Reference easeInOutExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeExponentialInOut());
```
*/
export function easeExponentialInOut() : any;
/** creates an EaseSineIn action. <br />
Reference easeInSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeSineIn());
```
*/
export function easeSineIn() : any;
/** Creates an EaseSineOut action easing object. <br />
Reference easeOutSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeSineOut());
```
*/
export function easeSineOut() : any;
/** creates the action easing object. <br />
Reference easeInOutSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeSineInOut());
```
*/
export function easeSineInOut() : any;
/** Creates the action easing obejct with the period in radians (default is 0.3). <br />
Reference easeInElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeElasticIn(3.0));
```
*/
export function easeElasticIn(period? : number) : any;
/** Creates the action easing object with the period in radians (default is 0.3). <br />
Reference easeOutElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeElasticOut(3.0));
```
*/
export function easeElasticOut(period? : number) : any;
/** Creates the action easing object with the period in radians (default is 0.3). <br />
Reference easeInOutElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
// example
action.easing(cc.easeElasticInOut(3.0));
```
*/
export function easeElasticInOut(period? : number) : any;
/** Creates the action easing object. <br />
Eased bounce effect at the beginning.
@example
```js
// example
action.easing(cc.easeBounceIn());
```
*/
export function easeBounceIn() : any;
/** Creates the action easing object. <br />
Eased bounce effect at the ending.
@example
```js
// example
action.easing(cc.easeBounceOut());
```
*/
export function easeBounceOut() : any;
/** Creates the action easing object. <br />
Eased bounce effect at the begining and ending.
@example
```js
// example
action.easing(cc.easeBounceInOut());
```
*/
export function easeBounceInOut() : any;
/** Creates the action easing object. <br />
In the opposite direction to move slowly, and then accelerated to the right direction.
@example
```js
// example
action.easing(cc.easeBackIn());
```
*/
export function easeBackIn() : any;
/** Creates the action easing object. <br />
Fast moving more than the finish, and then slowly back to the finish.
@example
```js
// example
action.easing(cc.easeBackOut());
```
*/
export function easeBackOut() : any;
/** Creates the action easing object. <br />
Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
@example
```js
// example
action.easing(cc.easeBackInOut());
```
*/
export function easeBackInOut() : any;
/** Creates the action easing object. <br />
Into the 4 reference point. <br />
To calculate the motion curve.
@param p0 The first bezier parameter
@param p1 The second bezier parameter
@param p2 The third bezier parameter
@param p3 The fourth bezier parameter
@example
```js
// example
action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
```
*/
export function easeBezierAction(p0 : number, p1 : number, p2 : number, p3 : number) : any;
/** Creates the action easing object. <br />
Reference easeInQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionIn());
```
*/
export function easeQuadraticActionIn() : any;
/** Creates the action easing object. <br />
Reference easeOutQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionOut());
```
*/
export function easeQuadraticActionOut() : any;
/** Creates the action easing object. <br />
Reference easeInOutQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionInOut());
```
*/
export function easeQuadraticActionInOut() : any;
/** Creates the action easing object. <br />
Reference easeIntQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuarticActionIn());
```
*/
export function easeQuarticActionIn() : any;
/** Creates the action easing object. <br />
Reference easeOutQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.QuarticActionOut());
```
*/
export function easeQuarticActionOut() : any;
/** Creates the action easing object. <br />
Reference easeInOutQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
*/
export function easeQuarticActionInOut() : any;
/** Creates the action easing object. <br />
Reference easeInQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuinticActionIn());
```
*/
export function easeQuinticActionIn() : any;
/** Creates the action easing object. <br />
Reference easeOutQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionOut());
```
*/
export function easeQuinticActionOut() : any;
/** Creates the action easing object. <br />
Reference easeInOutQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuinticActionInOut());
```
*/
export function easeQuinticActionInOut() : any;
/** Creates the action easing object. <br />
Reference easeInCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCircleActionIn());
```
*/
export function easeCircleActionIn() : any;
/** Creates the action easing object. <br />
Reference easeOutCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
*/
export function easeCircleActionOut() : any;
/** Creates the action easing object. <br />
Reference easeInOutCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCircleActionInOut());
```
*/
export function easeCircleActionInOut() : any;
/** Creates the action easing object. <br />
Reference easeInCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCubicActionIn());
```
*/
export function easeCubicActionIn() : any;
/** Creates the action easing object. <br />
Reference easeOutCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCubicActionOut());
```
*/
export function easeCubicActionOut() : any;
/** Creates the action easing object. <br />
Reference easeInOutCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
*/
export function easeCubicActionInOut() : any;
/** Show the Node.
@example
```js
// example
var showAction = cc.show();
```
*/
export function show() : ActionInstant;
/** Hide the node.
@example
```js
// example
var hideAction = cc.hide();
```
*/
export function hide() : ActionInstant;
/** Toggles the visibility of a node.
@example
```js
// example
var toggleVisibilityAction = cc.toggleVisibility();
```
*/
export function toggleVisibility() : ActionInstant;
/** Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
@example
```js
// example
var removeSelfAction = cc.removeSelf();
```
*/
export function removeSelf(isNeedCleanUp? : boolean) : ActionInstant;
/** Create a FlipX action to flip or unflip the target.
@param flip Indicate whether the target should be flipped or not
@example
```js
var flipXAction = cc.flipX(true);
```
*/
export function flipX(flip : boolean) : ActionInstant;
/** Create a FlipY action to flip or unflip the target.
@example
```js
var flipYAction = cc.flipY(true);
```
*/
export function flipY(flip : boolean) : ActionInstant;
/** Creates a Place action with a position.
@example
```js
// example
var placeAction = cc.place(cc.p(200, 200));
var placeAction = cc.place(200, 200);
```
*/
export function place(pos : Vec2|number, y? : number) : ActionInstant;
/** Creates the action with the callback
@param data data for function, it accepts all data types.
@example
```js
// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);
// CallFunc with data
var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
```
*/
export function callFunc(selector : Function, selectorTarget? : any|void, data? : any|void) : ActionInstant;
/** Helper constructor to create an array of sequenceable actions
The created action will run actions sequentially, one after another.
@example
```js
// example
// create sequence with actions
var seq = cc.sequence(act1, act2);
// create sequence with array
var seq = cc.sequence(actArray);
todo: It should be use new
```
*/
export function sequence(tempArray : any[]|FiniteTimeAction) : ActionInterval;
/** Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
@example
```js
// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
```
*/
export function repeat(action : FiniteTimeAction, times : number) : ActionInterval;
/** Create a acton which repeat forever
@example
```js
// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
```
*/
export function repeatForever(action : FiniteTimeAction) : ActionInterval;
/** Create a spawn action which runs several actions in parallel.
@example
```js
// example
var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
todo:It should be the direct use new
```
*/
export function spawn(tempArray : any[]|FiniteTimeAction) : FiniteTimeAction;
/** Rotates a Node object to a certain angle by modifying its rotation property. <br/>
The direction will be decided by the shortest angle.
@param duration duration in seconds
@param deltaAngleX deltaAngleX in degrees.
@param deltaAngleY deltaAngleY in degrees.
@example
```js
// example
var rotateTo = cc.rotateTo(2, 61.0);
```
*/
export function rotateTo(duration : number, deltaAngleX : number, deltaAngleY? : number) : ActionInterval;
/** Rotates a Node object clockwise a number of degrees by modifying its rotation property.
Relative to its properties to modify.
@param duration duration in seconds
@param deltaAngleX deltaAngleX in degrees
@param deltaAngleY deltaAngleY in degrees
@example
```js
// example
var actionBy = cc.rotateBy(2, 360);
```
*/
export function rotateBy(duration : number, deltaAngleX : number, deltaAngleY? : number) : ActionInterval;
/** Moves a Node object x,y pixels by modifying its position property. <br/>
x and y are relative to the position of the object. <br/>
Several MoveBy actions can be concurrently called, and the resulting <br/>
movement will be the sum of individual movements.
@param duration duration in seconds
@example
```js
// example
var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
```
*/
export function moveBy(duration : number, deltaPos : Vec2|number, deltaY : number) : ActionInterval;
/** Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
Several MoveTo actions can be concurrently called, and the resulting <br/>
movement will be the sum of individual movements.
@param duration duration in seconds
@example
```js
// example
var actionBy = cc.moveTo(2, cc.p(80, 80));
```
*/
export function moveTo(duration : number, position : Vec2, y : number) : ActionInterval;
/** Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
Changes to the specified value.
@param t time in seconds
@example
```js
// example
var actionTo = cc.skewTo(2, 37.2, -37.2);
```
*/
export function skewTo(t : number, sx : number, sy : number) : ActionInterval;
/** Skews a Node object by skewX and skewY degrees. <br />
Relative to its property modification.
@param t time in seconds
@param sx sx skew in degrees for X axis
@param sy sy skew in degrees for Y axis
@example
```js
// example
var actionBy = cc.skewBy(2, 0, -90);
```
*/
export function skewBy(t : number, sx : number, sy : number) : ActionInterval;
/** Moves a Node object simulating a parabolic jump movement by modifying it's position property.
Relative to its movement.
@example
```js
// example
var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
```
*/
export function jumpBy(duration : number, position : Vec2|number, y? : number, height : number, jumps : number) : ActionInterval;
/** Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
Jump to the specified location.
@example
```js
// example
var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
```
*/
export function jumpTo(duration : number, position : Vec2|number, y? : number, height : number, jumps : number) : ActionInterval;
/** An action that moves the target with a cubic Bezier curve by a certain distance.
Relative to its movement.
@param t time in seconds
@param c Array of points
@example
```js
// example
var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
var bezierForward = cc.bezierBy(3, bezier);
```
*/
export function bezierBy(t : number, c : any[]) : ActionInterval;
/** An action that moves the target with a cubic Bezier curve to a destination point.
@param c array of points
@example
```js
// example
var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
var bezierTo = cc.bezierTo(2, bezier);
```
*/
export function bezierTo(t : number, c : any[]) : ActionInterval;
/** Scales a Node object to a zoom factor by modifying it's scale property.
@param sx scale parameter in X
@param sy scale parameter in Y, if Null equal to sx
@example
```js
// example
// It scales to 0.5 in both X and Y.
var actionTo = cc.scaleTo(2, 0.5);
// It scales to 0.5 in x and 2 in Y
var actionTo = cc.scaleTo(2, 0.5, 2);
```
*/
export function scaleTo(duration : number, sx : number, sy? : number) : ActionInterval;
/** Scales a Node object a zoom factor by modifying it's scale property.
Relative to its changes.
@param duration duration in seconds
@param sx sx scale parameter in X
@param sy sy scale parameter in Y, if Null equal to sx
@example
```js
// example without sy, it scales by 2 both in X and Y
var actionBy = cc.scaleBy(2, 2);
//example with sy, it scales by 0.25 in X and 4.5 in Y
var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
```
*/
export function scaleBy(duration : number, sx : number, sy? : number|void) : ActionInterval;
/** Blinks a Node object by modifying it's visible property.
@param duration duration in seconds
@param blinks blinks in times
@example
```js
// example
var action = cc.blink(2, 10);
```
*/
export function blink(duration : number, blinks : number) : ActionInterval;
/** Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
@param opacity 0-255, 0 is transparent
@example
```js
// example
var action = cc.fadeTo(1.0, 0);
```
*/
export function fadeTo(duration : number, opacity : number) : ActionInterval;
/** Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
@param duration duration in seconds
@example
```js
//example
var action = cc.fadeIn(1.0);
```
*/
export function fadeIn(duration : number) : ActionInterval;
/** Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
@param d duration in seconds
@example
```js
// example
var action = cc.fadeOut(1.0);
```
*/
export function fadeOut(d : number) : ActionInterval;
/** Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
@param red 0-255
@param green 0-255
@param blue 0-255
@example
```js
// example
var action = cc.tintTo(2, 255, 0, 255);
```
*/
export function tintTo(duration : number, red : number, green : number, blue : number) : ActionInterval;
/** Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
Relative to their own color change.
@param duration duration in seconds
@example
```js
// example
var action = cc.tintBy(2, -127, -255, -127);
```
*/
export function tintBy(duration : number, deltaRed : number, deltaGreen : number, deltaBlue : number) : ActionInterval;
/** Delays the action a certain amount of seconds
@param d duration in seconds
@example
```js
// example
var delay = cc.delayTime(1);
```
*/
export function delayTime(d : number) : ActionInterval;
/** Executes an action in reverse order, from time=duration to time=0.
@example
```js
// example
var reverse = cc.reverseTime(this);
```
*/
export function reverseTime(action : FiniteTimeAction) : ActionInterval;
/** Constructor
*/
export function HashElement() : void;
/** cc.view is the shared view object. */
export var view : View;
export var director : Director;
/** cc.winSize is the alias object for the size of the current game window. */
export var winSize : Size;
export var game : Game;
/** Checks whether subclass is child of superclass or equals to superclass
*/
export function isChildClassOf(subclass : Function, superclass : Function) : boolean;
/** !#en Defines a CCClass using the given specification, please see [Class](/en/scripting/class/) for details.
!#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
@example
```js
// define base class
var Node = cc.Class();
// define sub class
var Sprite = cc.Class({
name: 'Sprite',
extends: Node,
ctor: function () {
this.url = "";
this.id = 0;
},
properties {
width: {
default: 128,
type: 'Integer',
tooltip: 'The width of sprite'
},
height: 128,
size: {
get: function () {
return cc.v2(this.width, this.height);
}
}
},
load: function () {
// load this.url
};
});
// instantiate
var obj = new Sprite();
obj.url = 'sprite.png';
obj.load();
// define static member
Sprite.count = 0;
Sprite.getBounds = function (spriteList) {
// ...
};
```
*/
export function Class(options : { name? : string; extends? : Function; ctor? : Function; properties? : any; statics? : any; mixins? : Function[]; editor? : any; update? : Function; lateUpdate? : Function; onLoad? : Function; start? : Function; onEnable? : Function; onDisable? : Function; onDestroy? : Function; onFocusInEditor? : Function; onLostFocusInEditor? : Function; onRestore? : Function; _getLocalBounds? : Function; }) : Function;
/** whether enable accelerometer event
*/
export function setAccelerometerEnabled(isEnable : boolean) : void;
/** set accelerometer interval value
*/
export function setAccelerometerInterval(interval : number) : void;
/** Checks whether the object is non-nil and not yet destroyed
*/
export function isValid(value : any) : boolean;
/** Specify that the input value must be integer in Inspector.
Also used to indicates that the elements in array should be type integer. */
export var Integer : string;
/** Indicates that the elements in array should be type double. */
export var Float : string;
/** Indicates that the elements in array should be type boolean. */
export var Boolean : string;
/** Indicates that the elements in array should be type string. */
export var String : string;
/** !#en Deserialize json to cc.Asset
!#zh 将 JSON 反序列化为对象实例。
当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
也不会将 uuid 保存到 result 对象中。
@param data the serialized cc.Asset json string or json object.
@param result additional loading result
*/
export function deserialize(data : string|any, result? : Details, options? : any) : any;
/** !#en Clones the object original and returns the clone.
See [Clone exists Entity](/en/scripting/create-destroy-entities/#instantiate)
!#zh 复制给定的对象
详细用法可参考[复制已有Entity](/zh/scripting/create-destroy-entities/#instantiate)
Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。
<del>对于 Entity / Component 等 Scene Object,如果对方也会被一起 Instantiate,则重定向到新的引用,否则保留为原来的引用。</del>
@param original An existing object that you want to make a copy of.
*/
export function instantiate(original : any) : any;
/** Finds a node by hierarchy path, the path is case-sensitive.
It will traverse the hierarchy by splitting the path using '/' character.
This function will still returns the node even if it is inactive.
It is recommended to not use this function every frame instead cache the result at startup.
*/
export function find(path : string, referenceNode? : Node) : Node;
/** Define an enum type. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list. Otherwise it will use the value specified by user who writes the enum definition.
@param obj a JavaScript literal object containing enum names and values
@example
```js
Texture.WrapMode = cc.Enum({
Repeat: -1,
Clamp: -1
});
// Texture.WrapMode.Repeat == 0
// Texture.WrapMode.Clamp == 1
// Texture.WrapMode[0] == "Repeat"
// Texture.WrapMode[1] == "Clamp"
var FlagType = cc.Enum({
Flag1: 1,
Flag2: 2,
Flag3: 4,
Flag4: 8,
});
var AtlasSizeList = cc.Enum({
128: 128,
256: 256,
512: 512,
1024: 1024,
});
```
*/
export function Enum(obj : any) : any;
/** Returns opposite of point.
*/
export function pNeg(point : Vec2) : Vec2;
/** Calculates sum of two points.
*/
export function pAdd(v1 : Vec2, v2 : Vec2) : Vec2;
/** Calculates difference of two points.
*/
export function pSub(v1 : Vec2, v2 : Vec2) : Vec2;
/** Returns point multiplied by given factor.
*/
export function pMult(point : Vec2, floatVar : number) : Vec2;
/** Calculates midpoint between two points.
*/
export function pMidpoint(v1 : Vec2, v2 : Vec2) : Vec2;
/** Calculates dot product of two points.
*/
export function pDot(v1 : Vec2, v2 : Vec2) : number;
/** Calculates cross product of two points.
*/
export function pCross(v1 : Vec2, v2 : Vec2) : number;
/** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0
*/
export function pPerp(point : Vec2) : Vec2;
/** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0
*/
export function pRPerp(point : Vec2) : Vec2;
/** Calculates the projection of v1 over v2.
*/
export function pProject(v1 : Vec2, v2 : Vec2) : Vec2;
/** Rotates two points.
*/
export function pRotate(v1 : Vec2, v2 : Vec2) : Vec2;
/** Unrotates two points.
*/
export function pUnrotate(v1 : Vec2, v2 : Vec2) : Vec2;
/** Calculates the square length of a cc.Vec2 (not calling sqrt() )
*/
export function pLengthSQ(v : Vec2) : number;
/** Calculates the square distance between two points (not calling sqrt() )
*/
export function pDistanceSQ(point1 : Vec2, point2 : Vec2) : number;
/** Calculates distance between point an origin
*/
export function pLength(v : Vec2) : number;
/** Calculates the distance between two points
*/
export function pDistance(v1 : Vec2, v2 : Vec2) : number;
/** Returns point multiplied to a length of 1.
*/
export function pNormalize(v : Vec2) : Vec2;
/** Converts radians to a normalized vector.
*/
export function pForAngle(a : number) : Vec2;
/** Converts a vector to radians.
*/
export function pToAngle(v : Vec2) : number;
/** Clamp a value between from and to.
*/