-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p5play.d.ts
3289 lines (3286 loc) · 95.5 KB
/
p5play.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
import * as p5 from 'p5';
declare global {
class P5Play {
/**
* Contains all the sprites in the sketch,
* but users should use the `allSprites` group.
*
* The keys are the sprite's unique ids.
* @type {Object.<number, Sprite>}
*/
sprites: {
[x: number]: Sprite;
};
/**
* Contains all the groups in the sketch,
*
* The keys are the group's unique ids.
* @type {Object.<number, Group>}
*/
groups: {
[x: number]: Group;
};
groupsCreated: number;
spritesCreated: number;
spritesDrawn: number;
/**
* Cache for loaded images.
*/
images: {};
/**
* Used for debugging, set to true to make p5play
* not load any images.
* @type {Boolean}
* @default false
*/
disableImages: boolean;
/**
* The default color palette, at index 0 of this array,
* has all the letters of the English alphabet mapped to colors.
* @type {Array}
*/
palettes: any[];
/**
* Friendly rounding eliminates some floating point errors.
* @type {Boolean}
* @default true
*/
friendlyRounding: boolean;
/**
* Groups that are removed using `group.remove()` are not
* fully deleted from `p5play.groups` by default, so their data
* is still accessible. Set to false to permanently delete
* removed groups, which reduces memory usage.
* @type {Boolean}
* @default true
*/
storeRemovedGroupRefs: boolean;
/**
* Information about the operating system being used to run
* p5play, retrieved from the `navigator` object.
*/
os: {};
context: string;
hasMouse: boolean;
standardizeKeyboard: boolean;
/**
* Displays the number of sprites drawn, the current FPS
* as well as the average, minimum, and maximum FPS achieved
* during the previous second.
*
* FPS in this context refers to how many frames per second your
* computer can generate, based on the physics calculations and any
* other processes necessary to generate a frame, but not
* including the delay between when frames are actually shown on
* the screen. The higher the FPS, the better your game is
* performing.
*
* You can use this function for approximate performance testing.
* But for the most accurate results, use your web browser's
* performance testing tools.
*
* Generally having less sprites and using a smaller canvas will
* make your game perform better. Also drawing images is faster
* than drawing shapes.
* @type {Boolean}
* @default false
*/
renderStats: boolean;
/**
* This function is called when an image is loaded. By default it
* does nothing, but it can be overridden.
*/
onImageLoad(): void;
}
var p5play: P5Play;
const log: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
/**
* Shortcut for console.log
* @type {Function}
* @param {...any} args
*/
/**
* @class
*/
class Sprite {
/**
* <a href="https://p5play.org/learn/sprite.html">
* Look at the Sprite reference pages before reading these docs.
* </a>
*
* The Sprite constructor can be used in many different ways.
*
* In fact it's so flexible that I've only listed out some of the
* most common ways it can be used in the examples section below.
* Try experimenting with it! It's likely to work the way you
* expect it to, if not you'll just get an error.
*
* Special feature! If the first parameter to this constructor is a
* loaded p5.Image, Ani, or name of a animation,
* then the Sprite will be created with that animation. If the
* dimensions of the sprite are not given, then the Sprite will be
* created using the dimensions of the animation.
*
* Every sprite you create is added to the `allSprites`
* group and put on the top draw order layer, in front of all
* previously created sprites.
*
* @param {Number} [x] - horizontal position of the sprite
* @param {Number} [y] - vertical position of the sprite
* @param {Number} [w] - width of the placeholder rectangle and of
* the collider until an image or new collider are set. *OR* If height is not
* set then this parameter becomes the diameter of the placeholder circle.
* @param {Number} [h] - height of the placeholder rectangle and of the collider
* until an image or new collider are set
* @param {String} [collider] - collider type is 'dynamic' by default, can be
* 'static', 'kinematic', or 'none'
* @example
*
* let spr = new Sprite();
*
* let rectangle = new Sprite(x, y, width, height);
*
* let circle = new Sprite(x, y, diameter);
*
* let spr = new Sprite(aniName, x, y);
*
* let line = new Sprite(x, y, [length, angle]);
*/
constructor(x?: number, y?: number, w?: number, h?: number, collider?: string, ...args: any[]);
/**
* Each sprite has a unique id number. Don't change it!
* They are useful for debugging.
* @type {Number}
*/
idNum: number;
/**
* Groups the sprite belongs to, including allSprites
* @type {Group[]}
* @default [allSprites]
*/
groups: Group[];
/**
* Keys are the animation label, values are Ani objects.
* @type {Anis}
*/
animations: Anis;
/**
* Joints that the sprite is attached to
* @type {Joint[]}
* @default []
*/
joints: Joint[];
/**
* If set to true, p5play will record all changes to the sprite's
* properties in its `mod` array. Intended to be used to enable
* online multiplayer.
* @type {Boolean}
* @default undefined
*/
watch: boolean;
/**
* An Object that has sprite property number codes as keys,
* these correspond to the index of the property in the
* Sprite.props array. The booleans values this object stores,
* indicate which properties were changed since the last frame.
* Useful for limiting the amount of sprite data sent in binary
* netcode to only the sprite properties that have been modified.
* @type {Object}
*/
mod: any;
set tileSize(val: number);
/**
* The tile size is used to change the size of one unit of
* measurement for the sprite.
*
* For example, if the tile size is 16, then a sprite with
* x=1 and y=1 will be drawn at position (16, 16) on the canvas.
* @type {Number}
* @default 1
*/
get tileSize(): number;
set collider(val: string);
/**
* The sprite's collider type. Default is "dynamic".
*
* The collider type can be one of the following strings:
* "dynamic", "static", "kinematic", "none".
*
* The letters "d", "s", "k", "n" can be used as shorthand.
*
* When a sprite with a collider type of "d", "s", or "k" is
* changed to "none", or vice versa, the sprite will
* maintain its current position, velocity, rotation, and
* rotation speed.
*
* Sprites can't have their collider type
* set to "none" if they have a polygon or chain collider,
* multiple colliders, or multiple sensors.
*
* To achieve the same effect as setting collider type
* to "none", use `.overlaps(allSprites)` to have your
* sprite overlap with all sprites.
*
* @type {String}
* @default 'dynamic'
*/
get collider(): string;
set x(val: number);
/**
* The horizontal position of the sprite.
* @type {Number}
*/
get x(): number;
set y(val: number);
/**
* The vertical position of the sprite.
* @type {Number}
*/
get y(): number;
set image(img: p5.Image);
/**
* The sprite's image or current frame of animation.
*
* When `sprite.image` is set, two properties are added:
*
* `sprite.image.offset` determines the x and y position the image
* should be drawn at relative to the sprite's center.
*
* `sprite.image.scale` determines the x and y scale of the image.
* @type {p5.Image}
*/
get image(): p5.Image;
/**
* Used to detect mouse events with the sprite.
* @type {_SpriteMouse}
*/
mouse: _SpriteMouse;
set shape(val: string);
/**
* The kind of shape: 'box', 'circle', 'chain', or 'polygon'.
*
* If a sprite with a circle shape has its shape type changed to
* chain or polygon, the circle will be turned into a dodecagon.
* @type {String}
* @default box
*/
get shape(): string;
set w(val: number);
/**
* The width of the sprite.
* @type {Number}
*/
get w(): number;
set h(val: number);
/**
* The height of the sprite.
* @type {Number}
*/
get h(): number;
/**
* The sprite's position on the previous frame.
* @type {object}
*/
prevPos: object;
prevRotation: number;
/**
* Text displayed at the center of the sprite.
* @type {String}
* @default undefined
*/
text: string;
/**
* Adds a collider (fixture) to the sprite's physics body.
*
* It accepts parameters in a similar format to the Sprite
* constructor except the first two parameters are x and y offsets,
* the distance new collider should be from the center of the sprite.
*
* This function also recalculates the sprite's mass based on the
* size of the new collider added to it. However, it does not move
* the sprite's center of mass, which makes adding multiple colliders
* to a sprite easier.
*
* For better physics simulation results, run the `resetCenterOfMass`
* function after you finish adding colliders to a sprite.
*
* One limitation of the current implementation is that sprites
* with multiple colliders can't have their collider
* type changed without losing every collider added to the
* sprite besides the first.
*
* @param {Number} offsetX - distance from the center of the sprite
* @param {Number} offsetY - distance from the center of the sprite
* @param {Number} w - width of the collider
* @param {Number} h - height of the collider
*/
addCollider(offsetX: number, offsetY: number, w: number, h: number, ...args: any[]): void;
body: any;
/**
* Adds a sensor to the sprite's physics body.
*
* Sensors can't displace or be displaced by colliders.
* Sensors don't have any mass or other physical properties.
* Sensors simply detect overlaps with other sensors.
*
* This function accepts parameters in a similar format to the Sprite
* constructor except the first two parameters are x and y offsets,
* the relative distance the new sensor should be from the center of
* the sprite.
*
* If a sensor is added to a sprite that has no collider (type "none")
* then internally it will be given a dynamic physics body that isn't
* affected by gravity so that the sensor can be added to it.
*
* @param {Number} offsetX - distance from the center of the sprite
* @param {Number} offsetY - distance from the center of the sprite
* @param {Number} w - width of the collider
* @param {Number} h - height of the collider
*/
addSensor(offsetX: number, offsetY: number, w: number, h: number, ...args: any[]): void;
set mass(val: number);
/**
* The mass of the sprite's physics body.
* @type {Number}
*/
get mass(): number;
set rotation(val: number);
/**
* The angle of the sprite's rotation, not the direction it's moving.
*
* If angleMode is set to "degrees", the value will be returned in
* a range of -180 to 180.
* @type {Number}
* @default 0
*/
get rotation(): number;
set vel(val: p5.Vector);
/**
* The sprite's velocity vector {x, y}
* @type {p5.Vector}
* @default {x: 0, y: 0}
*/
get vel(): p5.Vector;
/**
* Removes the physics body colliders from the sprite but not
* overlap sensors.
*/
removeColliders(): void;
/**
* Removes overlap sensors from the sprite.
*/
removeSensors(): void;
set animation(val: Ani);
/**
* Reference to the sprite's current animation.
* @type {Ani}
*/
get animation(): Ani;
set ani(val: Ani);
/**
* Reference to the sprite's current animation.
* @type {Ani}
*/
get ani(): Ani;
/**
* Keys are the animation label, values are Ani objects
* @type {Anis}
*/
get anis(): Anis;
set autoDraw(val: boolean);
/**
* autoDraw is a property of all groups that controls whether
* a group is automatically drawn to the screen after the end
* of each draw cycle.
*
* It only needs to be set to false once and then it will
* remain false for the rest of the sketch, unless changed.
* @type {Boolean}
* @default true
*/
get autoDraw(): boolean;
set allowSleeping(val: boolean);
/**
* This property disables the ability for a sprite to "sleep".
*
* "Sleeping" sprites are not included in the physics simulation, a
* sprite starts "sleeping" when it stops moving and doesn't collide
* with anything that it wasn't already touching.
* @type {Boolean}
* @default true
*/
get allowSleeping(): boolean;
set autoUpdate(val: boolean);
/**
* autoUpdate is a property of all groups that controls whether
* a group is automatically updated after the end of each draw
* cycle.
*
* It only needs to be set to false once and then it will
* remain false for the rest of the sketch, unless changed.
* @type {Boolean}
* @default true
*/
get autoUpdate(): boolean;
set bounciness(val: number);
/**
* The bounciness of the sprite's physics body.
* @type {Number}
* @default 0.2
*/
get bounciness(): number;
set rotationSpeed(val: number);
/**
* The speed of the sprite's rotation in angles per frame.
* @type {Number}
* @default 0
*/
get rotationSpeed(): number;
set color(val: p5.Color);
/**
* The sprite's current color. By default sprites get a random color.
* @type {p5.Color}
* @default random color
*/
get color(): p5.Color;
set colour(val: p5.Color);
/**
* Alias for color. colour is the British English spelling.
* @type {p5.Color}
* @default random color
*/
get colour(): p5.Color;
set fill(val: p5.Color);
/**
* Alias for sprite.fillColor
* @type {p5.Color}
* @default random color
*/
get fill(): p5.Color;
set fillColor(val: any);
/**
* Deprecated alias for sprite.fill, will be removed in the future.
* @deprecated
*/
get fillColor(): any;
set stroke(val: p5.Color);
/**
* Overrides sprite's stroke color. By default the stroke of a sprite
* is determined by its collider type, which can also be overridden
* by the sketch's stroke color.
* @type {p5.Color}
* @default undefined
*/
get stroke(): p5.Color;
set strokeColor(val: any);
/**
* Deprecated alias for sprite.stroke, will be removed in the future.
* @deprecated
*/
get strokeColor(): any;
set strokeWeight(val: number);
/**
* The sprite's stroke weight, the thickness of its outline.
* @type {Number}
* @default undefined
*/
get strokeWeight(): number;
set textColor(val: p5.Color);
/**
* The sprite's text fill color. Black by default.
* @type {p5.Color}
* @default black (#000000)
*/
get textColor(): p5.Color;
set textColour(val: any);
get textColour(): any;
set textFill(val: p5.Color);
/**
* The sprite's text fill color. Black by default.
* @type {p5.Color}
* @default black (#000000)
*/
get textFill(): p5.Color;
set textSize(val: number);
/**
* The sprite's text size, the sketch's current textSize by default.
* @type {Number}
*/
get textSize(): number;
set textStroke(val: p5.Color);
/**
* The sprite's text stroke color.
* No stroke by default, does not inherit from the sketch's stroke color.
* @type {p5.Color}
* @default undefined
*/
get textStroke(): p5.Color;
set textStrokeWeight(val: number);
/**
* The sprite's text stroke weight, the thickness of its outline.
* No stroke by default, does not inherit from the sketch's stroke weight.
* @type {Number}
* @default undefined
*/
get textStrokeWeight(): number;
set tile(val: string);
/**
* The tile string represents the sprite in a tile map.
* @type {String}
*/
get tile(): string;
set bearing(val: number);
/**
* A bearing indicates the direction that needs to be followed to
* reach a destination. Setting a sprite's bearing doesn't do
* anything by itself. You can apply a force at the sprite's
* bearing angle using the `applyForce` function.
* @type {Number}
* @example
* sprite.bearing = angle;
* sprite.applyForce(amount);
*/
get bearing(): number;
set debug(val: boolean);
/**
* If true, an outline of the sprite's collider will be drawn.
* @type {Boolean}
* @default false
*/
get debug(): boolean;
set density(val: number);
/**
* The density of the sprite's physics body.
* @type {Number}
* @default 5
*/
get density(): number;
set direction(val: number);
/**
* The angle of the sprite's movement.
* @type {Number}
* @default 0 ("right")
*/
get direction(): number;
set drag(val: number);
/**
* The amount of resistance a sprite has to being moved.
* @type {Number}
* @default 0
*/
get drag(): number;
set draw(val: Function);
/**
* Displays the sprite.
*
* This function is called automatically at the end of each
* sketch `draw` function call but it can also be run
* by users to customize the order sprites are drawn in relation
* to other stuff drawn to the canvas. Also see the sprite.layer
* property.
*
* A sprite's draw function can be overridden with a
* custom draw function, inside this function (0, 0) is the center of
* the sprite.
*
* Using this function actually calls the sprite's internal `_display`
* function, which sets up the canvas for drawing the sprite before
* calling the sprite's `_draw` function. See the example below for how to
* run the sprite's default `_draw` function inside your custom `draw` function.
*
* @type {Function}
* @example
* let defaultDraw = sprite._draw;
*
* sprite.draw = function() {
* // add custom code here
* defaultDraw();
* }
*/
get draw(): Function;
set dynamic(val: boolean);
/**
* True if the sprite's physics body is dynamic.
* @type {Boolean}
* @default true
*/
get dynamic(): boolean;
/**
* Returns the first node in a linked list of the planck physics
* body's fixtures.
*/
get fixture(): any;
/**
* Returns the first node in a linked list of the planck physics
* body's fixtures.
*/
get fixtureList(): any;
set friction(val: number);
/**
* The amount the sprite's physics body resists moving
* when rubbing against another physics body.
* @type {Number}
* @default 0.5
*/
get friction(): number;
set heading(val: string);
/**
* The sprite's heading. This is a string that can be set to
* "up", "down", "left", "right", "upRight", "upLeft", "downRight"
*
* It ignores cardinal direction word order, capitalization, spaces,
* underscores, and dashes.
* @type {String}
* @default undefined
*/
get heading(): string;
set img(val: p5.Image);
/**
* Alias for `sprite.image`.
* @type {p5.Image}
*/
get img(): p5.Image;
/**
* Read only. True if the sprite is moving.
* @type {Boolean}
*/
get isMoving(): boolean;
set isSuperFast(val: boolean);
/**
* Set this to true if the sprite goes really fast to prevent
* inaccurate physics simulation.
* @type {Boolean}
* @default false
*/
get isSuperFast(): boolean;
set kinematic(val: boolean);
/**
* True if the sprite's physics body is kinematic.
* @type {Boolean}
* @default false
*/
get kinematic(): boolean;
set layer(val: number);
/**
* By default sprites are drawn in the order they were created in.
* You can change the draw order by editing sprite's layer
* property. Sprites with the highest layer value get drawn first.
* @type {Number}
*/
get layer(): number;
set life(val: number);
/**
* When the physics simulation is progressed in `world.step`,
* each sprite's life is decreased by `world.timeScale`.
*
* If life becomes less than or equal to 0, the sprite will
* be removed.
*
* It must be set to a positive integer lower than the max value of
* a 32 bit signed integer, 2147483647, which is the default value
* representing infinite life. This limitation makes sprite netcode
* smaller. But don't worry, at 60 fps this gives users a definable
* sprite life range between 1 frame and ~411 days!
* @type {Number}
* @default 2147483647
*/
get life(): number;
/**
* Recalculates the sprite's mass based on its current
* density and size.
*
* Does not change the sprite's center of mass, to do so
* use the `resetCenterOfMass` function.
*/
resetMass(): void;
/**
* Recalculates the sprite's center of mass based on the masses of
* its fixtures and their positions. Moves the sprite's center to
* the new center of mass, but doesn't actually change the positions
* of its fixtures relative to the world.
*
* In p5play a sprite's center (position) is always the same as its
* center of mass and center of rotation.
*/
resetCenterOfMass(): void;
set mirror(val: any);
/**
* The sprite's mirror states.
* @type {Object}
* @property {Boolean} x - the sprite's horizontal mirror state
* @property {Boolean} y - the sprite's vertical mirror state
* @default {x: false, y: false}
*/
get mirror(): any;
set offset(val: any);
/**
* Offsetting the sprite moves the sprite's physics body relative
* to its center.
*
* The sprite's x and y properties represent its center in world
* coordinates. This point is also the sprite's center of rotation.
* @type {object}
* @property {Number} x - the sprite's horizontal offset
* @property {Number} y - the sprite's vertical offset
* @default {x: 0, y: 0}
*/
get offset(): any;
set opacity(val: number);
/**
* The sprite's opacity. 0 is transparent, 1 is opaque.
* @type {Number}
* @default 1
*/
get opacity(): number;
set previousPosition(val: any);
/**
* Alias for sprite.prevPos
* @type {Object}
*/
get previousPosition(): any;
set previousRotation(val: number);
/**
* Alias for sprite.prevRotation
* @type {Number}
*/
get previousRotation(): number;
set pixelPerfect(val: boolean);
/**
* By default p5play draws sprites with subpixel rendering.
*
* Set pixelPerfect to true to make p5play always display sprites
* at integer pixel precision. This is useful for making retro games.
* @type {Boolean}
* @default false
*/
get pixelPerfect(): boolean;
set removed(val: boolean);
/**
* If the sprite has been removed from the world.
* @type {Boolean}
* @default false
*/
get removed(): boolean;
set rotationDrag(val: number);
/**
* The amount the sprite resists rotating.
* @type {Number}
* @default 0
*/
get rotationDrag(): number;
set rotationLock(val: boolean);
/**
* If true, the sprite can not rotate.
* @type {Boolean}
* @default false
*/
get rotationLock(): boolean;
set scale(val: any);
/**
* Scale of the sprite's physics body. Default is {x: 1, y: 1}
*
* The getter for sprite.scale returns the scale as an object with
* x and y properties.
*
* The valueOf function for sprite.scale returns the scale as a
* number. This enables users to do things like `sprite.scale *= 2`
* to double the sprite's scale.
* @type {Number|Object}
* @default 1
*/
get scale(): any;
set sleeping(val: boolean);
/**
* Wake a sprite up or put it to sleep.
*
* "Sleeping" sprites are not included in the physics simulation, a
* sprite starts "sleeping" when it stops moving and doesn't collide
* with anything that it wasn't already touching.
* @type {Boolean}
* @default true
*/
get sleeping(): boolean;
set speed(val: number);
/**
* The sprite's speed.
*
* Setting speed to a negative value will make the sprite move
* 180 degrees opposite of its current direction angle.
* @type {Number}
* @default 0
*/
get speed(): number;
set static(val: boolean);
/**
* Is the sprite's physics collider static?
* @type {Boolean}
* @default false
*/
get static(): boolean;
set tint(val: p5.Color);
/**
* Tint color applied to the sprite when drawn.
*
* Note that this is not good for performance, you should probably
* pre-render the effect if you want to use it a lot.
* @type {p5.Color}
* @default undefined
*/
get tint(): p5.Color;
set tintColor(val: p5.Color);
/**
* Alias for sprite.tint
* @type {p5.Color}
* @default undefined
*/
get tintColor(): p5.Color;
/**
* The sprite's vertices, in vertex mode format.
* @type {Array}
*/
set vertices(val: any[]);
get vertices(): any[];
set visible(val: boolean);
/**
* If true the sprite is shown, if set to false the sprite is hidden.
*
* Becomes null when the sprite is off screen but will be drawn and
* set to true again if it goes back on screen.
* @type {Boolean}
* @default true
*/
get visible(): boolean;
set pos(val: p5.Vector);
/**
* The position vector {x, y}
* @type {p5.Vector}
*/
get pos(): p5.Vector;
set position(val: p5.Vector);
/**
* The position vector {x, y}
* @type {p5.Vector}
*/
get position(): p5.Vector;
/**
* The sprite's absolute position on the canvas.
* @readonly
*/
readonly get canvasPos(): any;
set hw(val: number);
/**
* Half the width of the sprite.
* @type {Number}
*/
get hw(): number;
set width(val: number);
/**
* The width of the sprite.
* @type {Number}
*/
get width(): number;
set halfWidth(val: number);
/**
* Half the width of the sprite.
* @type {Number}
*/
get halfWidth(): number;
set hh(val: number);
/**
* Half the height of the sprite.
* @type {Number}
*/
get hh(): number;
set height(val: number);
/**
* The height of the sprite.
* @type {Number}
*/
get height(): number;
set halfHeight(val: number);
/**
* Half the height of the sprite.
* @type {Number}
*/
get halfHeight(): number;
set d(val: number);
/**
* The diameter of a circular sprite.
* @type {Number}
*/
get d(): number;
set diameter(val: number);
/**
* The diameter of a circular sprite.
* @type {Number}
*/
get diameter(): number;
set r(val: number);
/**
* The radius of a circular sprite.
* @type {Number}
*/
get r(): number;
set radius(val: number);
/**
* The radius of a circular sprite.
* @type {Number}
*/
get radius(): number;
set update(val: Function);
/**
* You can set the sprite's update function to a custom
* update function which by default, will be run after every
* sketch draw call.
*
* This function updates the sprite's animation, mouse, and
*
* There's no way to individually update a sprite or group
* of sprites in the physics simulation though.
* @type {Function}
*/
get update(): Function;
set velocity(val: p5.Vector);
/**
* The sprite's velocity vector {x, y}
* @type {p5.Vector}
* @default {x: 0, y: 0}
*/
get velocity(): p5.Vector;
set gravityScale(val: number);
/**
* A ratio that defines how much the sprite is affected by gravity.
* @type {Number}
* @default 1
*/
get gravityScale(): number;
/**
* If this function is given a force amount, the force is applied
* at the angle of the sprite's current bearing. Force can
* also be given as a vector.
*
* The origin of the force can be given as a vector or as x and y
* coordinates. If no origin is given, the force is applied to the
* center of the sprite.
*
* @param {Number} amount
* @param {Vector} [origin]
* @example
* sprite.applyForce(amount);
* sprite.applyForce(amount, {x: originX, y: originY});
* sprite.applyForce(x, y);
* sprite.applyForce(x, y, {x: originX, y: originY});
* sprite.applyForce({x, y}, {x: originX, y: originY});
*/
applyForce(amount: number, origin?: Vector, ...args: any[]): void;
/**
* Applies a force that's scaled to the sprite's mass.
*
* @param {Number} amount
* @param {Vector} [origin]
*/
applyForceScaled(amount: number, origin?: Vector, ...args: any[]): void;
/**
* Applies a force to the sprite's center of mass attracting it to
* the given position.
*
* Radius and easing not implemented yet!
*
* @param {Number} x
* @param {Number} y
* @param {Number} force
* @param {Number} [radius] - infinite if not given
* @param {Number} [easing] - solid if not given
* @example
* sprite.attractTo(x, y, force);