q5play 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/py.typed +0 -0
- package/q5play.d.ts +1369 -144
- package/q5play.js +466 -125
- package/q5play.pyi +5007 -0
package/q5play.pyi
ADDED
|
@@ -0,0 +1,5007 @@
|
|
|
1
|
+
# Auto-generated from q5play.d.ts — do not edit by hand.
|
|
2
|
+
# Run: bun lang/types.js
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
from typing import Any, Callable, Type, TypeVar, Generic, overload
|
|
6
|
+
from collections.abc import Awaitable
|
|
7
|
+
from q5 import *
|
|
8
|
+
|
|
9
|
+
class Q5Play:
|
|
10
|
+
|
|
11
|
+
sprites: dict
|
|
12
|
+
"""
|
|
13
|
+
Contains all the sprites in the sketch.
|
|
14
|
+
|
|
15
|
+
Users should use the `allSprites` group instead
|
|
16
|
+
because this object includes deleted sprites.
|
|
17
|
+
|
|
18
|
+
The keys are the sprite's unique ids.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
groups: dict
|
|
22
|
+
"""
|
|
23
|
+
Contains all the groups in the sketch.
|
|
24
|
+
|
|
25
|
+
The keys are the group's unique ids.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
groupsCreated: float
|
|
29
|
+
|
|
30
|
+
spritesCreated: float
|
|
31
|
+
|
|
32
|
+
spritesDrawn: float
|
|
33
|
+
|
|
34
|
+
palettes: list[Any]
|
|
35
|
+
"""
|
|
36
|
+
The default color palette, at index 0 of this array,
|
|
37
|
+
has all the letters of the English alphabet mapped to colors.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
friendlyRounding: bool
|
|
41
|
+
"""
|
|
42
|
+
Friendly rounding makes some Sprite getters return nice rounded numbers
|
|
43
|
+
if a decimal value is within linear slop range (+/-0.005) or
|
|
44
|
+
angular slop range (+/-0.000582 radians) of a whole number.
|
|
45
|
+
|
|
46
|
+
This is because Box2D physics calculations can result in
|
|
47
|
+
floating point drift, which beginners wouldn't expect.
|
|
48
|
+
|
|
49
|
+
Setting to false can slightly improve performance.
|
|
50
|
+
|
|
51
|
+
Default: `true`
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
os: dict
|
|
55
|
+
"""Information about the operating system being used."""
|
|
56
|
+
|
|
57
|
+
context: str
|
|
58
|
+
|
|
59
|
+
hasMouse: bool
|
|
60
|
+
|
|
61
|
+
standardizeKeyboard: bool
|
|
62
|
+
|
|
63
|
+
renderStats: bool
|
|
64
|
+
"""
|
|
65
|
+
Displays the version of q5play being used,
|
|
66
|
+
the number of sprites being drawn
|
|
67
|
+
and a realtime graphing of the current FPS.
|
|
68
|
+
|
|
69
|
+
FPS in this context refers to how many frames per second your
|
|
70
|
+
computer can generate, only based on the physics calculations and
|
|
71
|
+
other processes necessary to generate a frame, but not
|
|
72
|
+
including the delay between when frames are actually shown on
|
|
73
|
+
the screen. The higher the FPS, the better your game is
|
|
74
|
+
performing.
|
|
75
|
+
|
|
76
|
+
You can use this function for approximate performance testing.
|
|
77
|
+
But for the most accurate results, use your web browser's
|
|
78
|
+
performance testing tools.
|
|
79
|
+
|
|
80
|
+
Generally having less sprites and using a smaller canvas will
|
|
81
|
+
make your game perform better. Also drawing images is faster
|
|
82
|
+
than drawing shapes.
|
|
83
|
+
|
|
84
|
+
Default: `false`
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def splashScreen(self) -> Awaitable[None]:
|
|
88
|
+
"""
|
|
89
|
+
"Made with q5play" [splash screen](https://en.wikipedia.org/wiki/Splash_screen) displayed during
|
|
90
|
+
initial page load by default.
|
|
91
|
+
"""
|
|
92
|
+
...
|
|
93
|
+
|
|
94
|
+
def update(self) -> None:
|
|
95
|
+
"""Runs automatically before each draw function call."""
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
def postDraw(self) -> None:
|
|
99
|
+
"""Runs automatically after each draw function call."""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
q5play: Q5Play
|
|
103
|
+
|
|
104
|
+
Box2D: Any
|
|
105
|
+
"""
|
|
106
|
+
Box2D v3 ported to WASM is the physics engine that
|
|
107
|
+
q5play uses for its physics simulation.
|
|
108
|
+
|
|
109
|
+
This variable enables direct access to the Box2D API for
|
|
110
|
+
advanced users who want to do things that aren't wrapped
|
|
111
|
+
by q5play.
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
class Shape:
|
|
115
|
+
"""
|
|
116
|
+
Don't create Shapes directly; use `sprite.addCollider()`
|
|
117
|
+
or `sprite.addSensor()` instead.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
sprite: Sprite
|
|
121
|
+
|
|
122
|
+
type: str
|
|
123
|
+
|
|
124
|
+
geom: Any
|
|
125
|
+
|
|
126
|
+
density: float
|
|
127
|
+
|
|
128
|
+
def applyWind(self, speed: float, angle: float, drag: float = ..., lift: float = ...) -> None:
|
|
129
|
+
...
|
|
130
|
+
|
|
131
|
+
def scaleBy(self, scaleX: float, scaleY: float = ...) -> None:
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
def delete(self) -> None:
|
|
135
|
+
...
|
|
136
|
+
|
|
137
|
+
class Collider(Shape):
|
|
138
|
+
"""
|
|
139
|
+
Colliders are added to a sprite's physics body to cause
|
|
140
|
+
physical collisions with other sprites.
|
|
141
|
+
|
|
142
|
+
Don't create Colliders directly; use Sprite.addCollider() instead.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
friction: float
|
|
146
|
+
|
|
147
|
+
bounciness: float
|
|
148
|
+
|
|
149
|
+
density: float
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def rollingResistance(self) -> float:
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
@rollingResistance.setter
|
|
156
|
+
def rollingResistance(self, val: float) -> None: ...
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def surfaceSpeed(self) -> float:
|
|
160
|
+
...
|
|
161
|
+
|
|
162
|
+
@surfaceSpeed.setter
|
|
163
|
+
def surfaceSpeed(self, val: float) -> None: ...
|
|
164
|
+
|
|
165
|
+
class Sensor(Shape):
|
|
166
|
+
"""
|
|
167
|
+
Sensor are added to a sprite's physics body to detect overlaps
|
|
168
|
+
without causing physical collisions.
|
|
169
|
+
|
|
170
|
+
Don't create Sensors directly; use Sprite.addSensor() instead.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
_isSensor: bool
|
|
174
|
+
|
|
175
|
+
density: float
|
|
176
|
+
|
|
177
|
+
class Visual:
|
|
178
|
+
"""
|
|
179
|
+
A Visual object stores an image or animation(s)
|
|
180
|
+
which can be displayed with respect to the camera.
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
def x(self) -> float:
|
|
185
|
+
"""Horizontal position of the visual."""
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
@x.setter
|
|
189
|
+
def x(self, val: float) -> None: ...
|
|
190
|
+
|
|
191
|
+
@property
|
|
192
|
+
def y(self) -> float:
|
|
193
|
+
"""Vertical position of the visual."""
|
|
194
|
+
...
|
|
195
|
+
|
|
196
|
+
@y.setter
|
|
197
|
+
def y(self, val: float) -> None: ...
|
|
198
|
+
|
|
199
|
+
vx: float
|
|
200
|
+
"""Horizontal velocity of the visual."""
|
|
201
|
+
|
|
202
|
+
vy: float
|
|
203
|
+
"""Vertical velocity of the visual."""
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def draw(self) -> Any:
|
|
207
|
+
"""Draws the visual on the canvas."""
|
|
208
|
+
...
|
|
209
|
+
|
|
210
|
+
@draw.setter
|
|
211
|
+
def draw(self, val: Any) -> None: ...
|
|
212
|
+
|
|
213
|
+
@property
|
|
214
|
+
def img(self) -> Image:
|
|
215
|
+
"""Current image or frame of animation being displayed."""
|
|
216
|
+
...
|
|
217
|
+
|
|
218
|
+
@img.setter
|
|
219
|
+
def img(self, val: str | Image) -> None: ...
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def ani(self) -> Ani:
|
|
223
|
+
"""Current animation."""
|
|
224
|
+
...
|
|
225
|
+
|
|
226
|
+
@ani.setter
|
|
227
|
+
def ani(self, val: Ani) -> None: ...
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
def anis(self) -> Anis:
|
|
231
|
+
"""
|
|
232
|
+
Stores animations.
|
|
233
|
+
Keys are the animation label, values are Ani objects
|
|
234
|
+
"""
|
|
235
|
+
...
|
|
236
|
+
|
|
237
|
+
def addAni(self, spriteSheetURL: str, frameCount: float) -> Awaitable[None]:
|
|
238
|
+
"""
|
|
239
|
+
Adds an animation to the Sprite or Visual.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
243
|
+
frameCount: the number of frames in the sprite sheet
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
A promise that fulfills when the animation is loaded
|
|
247
|
+
"""
|
|
248
|
+
...
|
|
249
|
+
|
|
250
|
+
@overload
|
|
251
|
+
def addAnis(self, atlases: dict) -> Awaitable[None]:
|
|
252
|
+
"""
|
|
253
|
+
Add multiple animations to the Sprite or Visual.
|
|
254
|
+
|
|
255
|
+
Args:
|
|
256
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
257
|
+
|
|
258
|
+
Returns:
|
|
259
|
+
A promise that fulfills when the animations are loaded
|
|
260
|
+
"""
|
|
261
|
+
...
|
|
262
|
+
|
|
263
|
+
@overload
|
|
264
|
+
def addAnis(self, spriteSheetURL: str, atlases: dict) -> Awaitable[None]:
|
|
265
|
+
"""
|
|
266
|
+
Add multiple animations to the Sprite or Visual.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
270
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
A promise that fulfills when the animations are loaded
|
|
274
|
+
"""
|
|
275
|
+
...
|
|
276
|
+
|
|
277
|
+
@overload
|
|
278
|
+
def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
|
|
279
|
+
"""
|
|
280
|
+
Add multiple animations to the Sprite or Visual.
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
284
|
+
frameSize: the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")
|
|
285
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
286
|
+
|
|
287
|
+
Returns:
|
|
288
|
+
A promise that fulfills when the animations are loaded
|
|
289
|
+
"""
|
|
290
|
+
...
|
|
291
|
+
|
|
292
|
+
def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
|
|
293
|
+
...
|
|
294
|
+
|
|
295
|
+
def changeAni(self, name: str) -> None:
|
|
296
|
+
"""
|
|
297
|
+
Changes the sprite's animation. Use `addAni` to define the
|
|
298
|
+
animation(s) first.
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
name: the name of the animation to switch to
|
|
302
|
+
"""
|
|
303
|
+
...
|
|
304
|
+
|
|
305
|
+
def playAni(self, name: str) -> Awaitable[None]:
|
|
306
|
+
"""
|
|
307
|
+
Plays an animation.
|
|
308
|
+
|
|
309
|
+
You can put special modifier characters before the name:
|
|
310
|
+
- "!" plays it backwards
|
|
311
|
+
- ">" or "<" horizontally flips it
|
|
312
|
+
- "^" vertically flips it
|
|
313
|
+
|
|
314
|
+
Args:
|
|
315
|
+
name: the name of the animation to play
|
|
316
|
+
|
|
317
|
+
Returns:
|
|
318
|
+
A promise that fulfills when the animation completes
|
|
319
|
+
"""
|
|
320
|
+
...
|
|
321
|
+
|
|
322
|
+
def playAnis(self, *sequence: str) -> Awaitable[None]:
|
|
323
|
+
"""
|
|
324
|
+
Plays a sequence of animations.
|
|
325
|
+
|
|
326
|
+
You can put special modifier characters before each ani name:
|
|
327
|
+
- "!" plays it backwards
|
|
328
|
+
- ">" or "<" horizontally flips it
|
|
329
|
+
- "^" vertically flips it
|
|
330
|
+
|
|
331
|
+
You can put sequence modifiers at the end of the sequence:
|
|
332
|
+
- "**" loops it indefinitely
|
|
333
|
+
- ";;" stops it on the last ani's last frame
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
sequence: the names of animations
|
|
337
|
+
|
|
338
|
+
Returns:
|
|
339
|
+
A promise that fulfills when the sequence completes
|
|
340
|
+
"""
|
|
341
|
+
...
|
|
342
|
+
|
|
343
|
+
DYNAMIC: str
|
|
344
|
+
|
|
345
|
+
DYN: str
|
|
346
|
+
|
|
347
|
+
STATIC: str
|
|
348
|
+
|
|
349
|
+
STA: str
|
|
350
|
+
|
|
351
|
+
KINEMATIC: str
|
|
352
|
+
|
|
353
|
+
KIN: str
|
|
354
|
+
|
|
355
|
+
class Sprite(Visual):
|
|
356
|
+
"""A Sprite has a Box2D physics body with a collider (by default), which can interact with other sprites in the physics simulation."""
|
|
357
|
+
|
|
358
|
+
@overload
|
|
359
|
+
@classmethod
|
|
360
|
+
def new(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
361
|
+
|
|
362
|
+
@overload
|
|
363
|
+
@classmethod
|
|
364
|
+
def new(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
365
|
+
|
|
366
|
+
@overload
|
|
367
|
+
@classmethod
|
|
368
|
+
def new(cls, x: float, y: float, d: float, physicsType: str = ...) -> 'Sprite': ...
|
|
369
|
+
|
|
370
|
+
@overload
|
|
371
|
+
@classmethod
|
|
372
|
+
def new(cls, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
|
|
373
|
+
|
|
374
|
+
@overload
|
|
375
|
+
@classmethod
|
|
376
|
+
def new(cls, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
|
|
377
|
+
|
|
378
|
+
@overload
|
|
379
|
+
@classmethod
|
|
380
|
+
def new(cls, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
|
|
381
|
+
|
|
382
|
+
@overload
|
|
383
|
+
@classmethod
|
|
384
|
+
def new(cls, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> 'Sprite': ...
|
|
385
|
+
|
|
386
|
+
@overload
|
|
387
|
+
@classmethod
|
|
388
|
+
def new(cls, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
|
|
389
|
+
|
|
390
|
+
@overload
|
|
391
|
+
@classmethod
|
|
392
|
+
def new(cls, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
393
|
+
|
|
394
|
+
@overload
|
|
395
|
+
@classmethod
|
|
396
|
+
def new(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
397
|
+
|
|
398
|
+
@overload
|
|
399
|
+
@classmethod
|
|
400
|
+
def new(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
401
|
+
|
|
402
|
+
@overload
|
|
403
|
+
@classmethod
|
|
404
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> 'Sprite': ...
|
|
405
|
+
|
|
406
|
+
@overload
|
|
407
|
+
@classmethod
|
|
408
|
+
def new(cls, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
|
|
409
|
+
|
|
410
|
+
@overload
|
|
411
|
+
@classmethod
|
|
412
|
+
def new(cls, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
|
|
413
|
+
|
|
414
|
+
@overload
|
|
415
|
+
@classmethod
|
|
416
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> 'Sprite': ...
|
|
417
|
+
|
|
418
|
+
@overload
|
|
419
|
+
@classmethod
|
|
420
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> 'Sprite': ...
|
|
421
|
+
|
|
422
|
+
@overload
|
|
423
|
+
@classmethod
|
|
424
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> 'Sprite': ...
|
|
425
|
+
|
|
426
|
+
@overload
|
|
427
|
+
@classmethod
|
|
428
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite': ...
|
|
429
|
+
|
|
430
|
+
@classmethod
|
|
431
|
+
def new(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> 'Sprite':
|
|
432
|
+
...
|
|
433
|
+
|
|
434
|
+
@overload
|
|
435
|
+
def __init__(self, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> None: ...
|
|
436
|
+
|
|
437
|
+
@overload
|
|
438
|
+
def __init__(self, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> None: ...
|
|
439
|
+
|
|
440
|
+
@overload
|
|
441
|
+
def __init__(self, x: float, y: float, d: float, physicsType: str = ...) -> None: ...
|
|
442
|
+
|
|
443
|
+
@overload
|
|
444
|
+
def __init__(self, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> None: ...
|
|
445
|
+
|
|
446
|
+
@overload
|
|
447
|
+
def __init__(self, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
|
|
448
|
+
|
|
449
|
+
@overload
|
|
450
|
+
def __init__(self, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
|
|
451
|
+
|
|
452
|
+
@overload
|
|
453
|
+
def __init__(self, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> None: ...
|
|
454
|
+
|
|
455
|
+
@overload
|
|
456
|
+
def __init__(self, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> None: ...
|
|
457
|
+
|
|
458
|
+
@overload
|
|
459
|
+
def __init__(self, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
|
|
460
|
+
|
|
461
|
+
@overload
|
|
462
|
+
def __init__(self, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> None: ...
|
|
463
|
+
|
|
464
|
+
@overload
|
|
465
|
+
def __init__(self, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> None: ...
|
|
466
|
+
|
|
467
|
+
@overload
|
|
468
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> None: ...
|
|
469
|
+
|
|
470
|
+
@overload
|
|
471
|
+
def __init__(self, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> None: ...
|
|
472
|
+
|
|
473
|
+
@overload
|
|
474
|
+
def __init__(self, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
|
|
475
|
+
|
|
476
|
+
@overload
|
|
477
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> None: ...
|
|
478
|
+
|
|
479
|
+
@overload
|
|
480
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> None: ...
|
|
481
|
+
|
|
482
|
+
@overload
|
|
483
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> None: ...
|
|
484
|
+
|
|
485
|
+
@overload
|
|
486
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
|
|
487
|
+
|
|
488
|
+
def __init__(self, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> None: ...
|
|
489
|
+
|
|
490
|
+
@overload
|
|
491
|
+
@classmethod
|
|
492
|
+
def withSensor(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
493
|
+
|
|
494
|
+
@overload
|
|
495
|
+
@classmethod
|
|
496
|
+
def withSensor(cls, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
497
|
+
|
|
498
|
+
@overload
|
|
499
|
+
@classmethod
|
|
500
|
+
def withSensor(cls, x: float, y: float, d: float, physicsType: str = ...) -> Sprite: ...
|
|
501
|
+
|
|
502
|
+
@overload
|
|
503
|
+
@classmethod
|
|
504
|
+
def withSensor(cls, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
|
|
505
|
+
|
|
506
|
+
@overload
|
|
507
|
+
@classmethod
|
|
508
|
+
def withSensor(cls, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
|
|
509
|
+
|
|
510
|
+
@overload
|
|
511
|
+
@classmethod
|
|
512
|
+
def withSensor(cls, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
|
|
513
|
+
|
|
514
|
+
@overload
|
|
515
|
+
@classmethod
|
|
516
|
+
def withSensor(cls, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> Sprite: ...
|
|
517
|
+
|
|
518
|
+
@overload
|
|
519
|
+
@classmethod
|
|
520
|
+
def withSensor(cls, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
|
|
521
|
+
|
|
522
|
+
@overload
|
|
523
|
+
@classmethod
|
|
524
|
+
def withSensor(cls, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
525
|
+
|
|
526
|
+
@overload
|
|
527
|
+
@classmethod
|
|
528
|
+
def withSensor(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
529
|
+
|
|
530
|
+
@overload
|
|
531
|
+
@classmethod
|
|
532
|
+
def withSensor(cls, ani: str | Ani | Image, x: float = ..., y: float = ..., w: float = ..., h: float = ..., roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
533
|
+
|
|
534
|
+
@overload
|
|
535
|
+
@classmethod
|
|
536
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, d: float, physicsType: str = ...) -> Sprite: ...
|
|
537
|
+
|
|
538
|
+
@overload
|
|
539
|
+
@classmethod
|
|
540
|
+
def withSensor(cls, ani: str | Ani | Image, points: list[tuple[float, float]], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
|
|
541
|
+
|
|
542
|
+
@overload
|
|
543
|
+
@classmethod
|
|
544
|
+
def withSensor(cls, ani: str | Ani | Image, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
|
|
545
|
+
|
|
546
|
+
@overload
|
|
547
|
+
@classmethod
|
|
548
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, vertices: list[tuple[float, float]], physicsType: str = ...) -> Sprite: ...
|
|
549
|
+
|
|
550
|
+
@overload
|
|
551
|
+
@classmethod
|
|
552
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], physicsType: str = ...) -> Sprite: ...
|
|
553
|
+
|
|
554
|
+
@overload
|
|
555
|
+
@classmethod
|
|
556
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, distAngles: list[float], roundedRadius: float, physicsType: str = ...) -> Sprite: ...
|
|
557
|
+
|
|
558
|
+
@overload
|
|
559
|
+
@classmethod
|
|
560
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite: ...
|
|
561
|
+
|
|
562
|
+
@classmethod
|
|
563
|
+
def withSensor(cls, ani: str | Ani | Image, x: float, y: float, sideLength: float, polygonName: str, roundedRadius: float = ..., physicsType: str = ...) -> Sprite:
|
|
564
|
+
...
|
|
565
|
+
|
|
566
|
+
@property
|
|
567
|
+
def physics(self) -> str:
|
|
568
|
+
"""
|
|
569
|
+
The physics type of the sprite, which determines how it interacts with
|
|
570
|
+
other sprites in the physics simulation.
|
|
571
|
+
|
|
572
|
+
It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
573
|
+
|
|
574
|
+
Default: `"dynamic"`
|
|
575
|
+
"""
|
|
576
|
+
...
|
|
577
|
+
|
|
578
|
+
@physics.setter
|
|
579
|
+
def physics(self, val: str) -> None: ...
|
|
580
|
+
|
|
581
|
+
@property
|
|
582
|
+
def physicsType(self) -> str:
|
|
583
|
+
"""
|
|
584
|
+
The physics type of the sprite, which determines how it interacts with
|
|
585
|
+
other sprites in the physics simulation.
|
|
586
|
+
|
|
587
|
+
It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
588
|
+
|
|
589
|
+
Default: `"dynamic"`
|
|
590
|
+
"""
|
|
591
|
+
...
|
|
592
|
+
|
|
593
|
+
@physicsType.setter
|
|
594
|
+
def physicsType(self, val: str) -> None: ...
|
|
595
|
+
|
|
596
|
+
@property
|
|
597
|
+
def physicsEnabled(self) -> bool:
|
|
598
|
+
"""
|
|
599
|
+
If true, the sprite's physics body is included in the physics simulation.
|
|
600
|
+
|
|
601
|
+
Default: `true`
|
|
602
|
+
"""
|
|
603
|
+
...
|
|
604
|
+
|
|
605
|
+
@physicsEnabled.setter
|
|
606
|
+
def physicsEnabled(self, val: bool) -> None: ...
|
|
607
|
+
|
|
608
|
+
idNum: float
|
|
609
|
+
"""
|
|
610
|
+
Each sprite has a unique id number. Don't change it!
|
|
611
|
+
They are useful for debugging.
|
|
612
|
+
"""
|
|
613
|
+
|
|
614
|
+
bdID: Any
|
|
615
|
+
"""The Box2D body id for the sprite's physics body. Don't change it!"""
|
|
616
|
+
|
|
617
|
+
groups: list[Group]
|
|
618
|
+
"""
|
|
619
|
+
Groups the sprite belongs to.
|
|
620
|
+
|
|
621
|
+
Default: `[allSprites]`
|
|
622
|
+
"""
|
|
623
|
+
|
|
624
|
+
animations: Anis
|
|
625
|
+
"""Keys are the animation label, values are Ani objects."""
|
|
626
|
+
|
|
627
|
+
colliders: list[Collider]
|
|
628
|
+
"""Array of colliders that are part of the sprite's physics body."""
|
|
629
|
+
|
|
630
|
+
sensors: list[Sensor]
|
|
631
|
+
"""
|
|
632
|
+
Array of sensors that are part of the sprite's physics body.
|
|
633
|
+
Sensors are used to detect overlaps without causing physical collisions.
|
|
634
|
+
"""
|
|
635
|
+
|
|
636
|
+
joints: list[Joint]
|
|
637
|
+
"""
|
|
638
|
+
Joints that the sprite is attached to.
|
|
639
|
+
|
|
640
|
+
Default: `[]`
|
|
641
|
+
"""
|
|
642
|
+
|
|
643
|
+
watch: bool
|
|
644
|
+
"""
|
|
645
|
+
If set to true, q5play will record all changes to the sprite's
|
|
646
|
+
properties in its `mod` array. Intended to be used to enable
|
|
647
|
+
online multiplayer.
|
|
648
|
+
|
|
649
|
+
Default: `undefined`
|
|
650
|
+
"""
|
|
651
|
+
|
|
652
|
+
mod: dict
|
|
653
|
+
"""
|
|
654
|
+
Modification tracking object.
|
|
655
|
+
|
|
656
|
+
It has sprite property number codes as keys,
|
|
657
|
+
these correspond to the index of the property in the
|
|
658
|
+
Sprite.props array, and boolean values, that
|
|
659
|
+
indicate which properties were changed since the last frame.
|
|
660
|
+
|
|
661
|
+
Useful for limiting the amount of sprite data sent in netcode
|
|
662
|
+
to only the sprite properties that have been modified.
|
|
663
|
+
"""
|
|
664
|
+
|
|
665
|
+
@property
|
|
666
|
+
def x(self) -> float:
|
|
667
|
+
"""The horizontal position of the sprite."""
|
|
668
|
+
...
|
|
669
|
+
|
|
670
|
+
@x.setter
|
|
671
|
+
def x(self, val: float) -> None: ...
|
|
672
|
+
|
|
673
|
+
@property
|
|
674
|
+
def y(self) -> float:
|
|
675
|
+
"""The vertical position of the sprite."""
|
|
676
|
+
...
|
|
677
|
+
|
|
678
|
+
@y.setter
|
|
679
|
+
def y(self, val: float) -> None: ...
|
|
680
|
+
|
|
681
|
+
@property
|
|
682
|
+
def w(self) -> float:
|
|
683
|
+
"""The width of the sprite."""
|
|
684
|
+
...
|
|
685
|
+
|
|
686
|
+
@w.setter
|
|
687
|
+
def w(self, val: float) -> None: ...
|
|
688
|
+
|
|
689
|
+
@property
|
|
690
|
+
def h(self) -> float:
|
|
691
|
+
"""The height of the sprite."""
|
|
692
|
+
...
|
|
693
|
+
|
|
694
|
+
@h.setter
|
|
695
|
+
def h(self, val: float) -> None: ...
|
|
696
|
+
|
|
697
|
+
prevX: float
|
|
698
|
+
"""The sprite's x position on the previous frame."""
|
|
699
|
+
|
|
700
|
+
prevY: float
|
|
701
|
+
"""The sprite's y position on the previous frame."""
|
|
702
|
+
|
|
703
|
+
prevRotation: float
|
|
704
|
+
"""The sprite's rotation on the previous frame."""
|
|
705
|
+
|
|
706
|
+
text: str
|
|
707
|
+
"""
|
|
708
|
+
Text displayed at the center of the sprite.
|
|
709
|
+
|
|
710
|
+
Default: `undefined`
|
|
711
|
+
"""
|
|
712
|
+
|
|
713
|
+
def addCollider(self, offsetX: float, offsetY: float, w: float = ..., h: float = ..., roundedRadius: float = ...) -> None:
|
|
714
|
+
"""
|
|
715
|
+
Adds a collider to the sprite's physics body.
|
|
716
|
+
|
|
717
|
+
It accepts parameters in a similar format to the Sprite
|
|
718
|
+
constructor except the first two parameters are x and y offsets,
|
|
719
|
+
the distance new collider should be from the center of the sprite.
|
|
720
|
+
|
|
721
|
+
This function also recalculates the sprite's mass based on the
|
|
722
|
+
size of the new collider added to it. However, it does not move
|
|
723
|
+
the sprite's center of mass, which makes adding multiple colliders
|
|
724
|
+
to a sprite easier.
|
|
725
|
+
|
|
726
|
+
Args:
|
|
727
|
+
offsetX: distance from the center of the sprite
|
|
728
|
+
offsetY: distance from the center of the sprite
|
|
729
|
+
w: width of the collider
|
|
730
|
+
h: height of the collider
|
|
731
|
+
roundedRadius: corner radius for a rounded box collider
|
|
732
|
+
"""
|
|
733
|
+
...
|
|
734
|
+
|
|
735
|
+
def addSensor(self, offsetX: float, offsetY: float, w: float = ..., h: float = ..., roundedRadius: float = ...) -> None:
|
|
736
|
+
"""
|
|
737
|
+
Adds an overlap sensor to the sprite's physics body.
|
|
738
|
+
|
|
739
|
+
Sensors can't displace or be displaced by colliders.
|
|
740
|
+
Sensors don't have any mass or other physical properties.
|
|
741
|
+
Sensors simply detect overlaps.
|
|
742
|
+
|
|
743
|
+
This function accepts parameters in a similar format to the Sprite
|
|
744
|
+
constructor except the first two parameters are x and y offsets,
|
|
745
|
+
the relative distance the new sensor should be from the center of
|
|
746
|
+
the sprite.
|
|
747
|
+
|
|
748
|
+
Args:
|
|
749
|
+
offsetX: distance from the center of the sprite
|
|
750
|
+
offsetY: distance from the center of the sprite
|
|
751
|
+
w: width of the collider
|
|
752
|
+
h: height of the collider
|
|
753
|
+
roundedRadius: corner radius for a rounded box sensor
|
|
754
|
+
"""
|
|
755
|
+
...
|
|
756
|
+
|
|
757
|
+
@property
|
|
758
|
+
def mass(self) -> float:
|
|
759
|
+
"""The mass of the sprite's physics body."""
|
|
760
|
+
...
|
|
761
|
+
|
|
762
|
+
@mass.setter
|
|
763
|
+
def mass(self, val: float) -> None: ...
|
|
764
|
+
|
|
765
|
+
@property
|
|
766
|
+
def centerOfMass(self) -> dict:
|
|
767
|
+
"""
|
|
768
|
+
The center of mass of the sprite's physics body, the point at which
|
|
769
|
+
the physics body is balanced and rotates around. By default it's the
|
|
770
|
+
same as the sprite's position, but it can be changed with this setter.
|
|
771
|
+
"""
|
|
772
|
+
...
|
|
773
|
+
|
|
774
|
+
@centerOfMass.setter
|
|
775
|
+
def centerOfMass(self, val: dict) -> None: ...
|
|
776
|
+
|
|
777
|
+
@property
|
|
778
|
+
def fixedCenterOfMass(self) -> bool:
|
|
779
|
+
"""
|
|
780
|
+
If true, the center of mass of the sprite's physics body is fixed to
|
|
781
|
+
the sprite's [x, y] position.
|
|
782
|
+
|
|
783
|
+
It prevents the center of mass from being recalculated (moved) when adding or
|
|
784
|
+
removing colliders or sensors. Set it to false to allow dynamic center of mass
|
|
785
|
+
recalculation.
|
|
786
|
+
|
|
787
|
+
Default: `true`
|
|
788
|
+
"""
|
|
789
|
+
...
|
|
790
|
+
|
|
791
|
+
@fixedCenterOfMass.setter
|
|
792
|
+
def fixedCenterOfMass(self, val: bool) -> None: ...
|
|
793
|
+
|
|
794
|
+
def resetMass(self) -> None:
|
|
795
|
+
"""
|
|
796
|
+
Recalculates the sprite's mass based on its current
|
|
797
|
+
density and size.
|
|
798
|
+
"""
|
|
799
|
+
...
|
|
800
|
+
|
|
801
|
+
@property
|
|
802
|
+
def rotation(self) -> float:
|
|
803
|
+
"""
|
|
804
|
+
The angle of the sprite's rotation, not the direction it's moving.
|
|
805
|
+
|
|
806
|
+
If angleMode is set to "degrees", the value will be returned in
|
|
807
|
+
a range of -180 to 180.
|
|
808
|
+
|
|
809
|
+
Default: `0`
|
|
810
|
+
"""
|
|
811
|
+
...
|
|
812
|
+
|
|
813
|
+
@rotation.setter
|
|
814
|
+
def rotation(self, val: float) -> None: ...
|
|
815
|
+
|
|
816
|
+
def deleteColliders(self) -> None:
|
|
817
|
+
"""Removes colliders from the sprite's physics body."""
|
|
818
|
+
...
|
|
819
|
+
|
|
820
|
+
def deleteSensors(self) -> None:
|
|
821
|
+
"""Removes overlap sensors from the sprite's physics body."""
|
|
822
|
+
...
|
|
823
|
+
|
|
824
|
+
@property
|
|
825
|
+
def autoUpdate(self) -> bool:
|
|
826
|
+
"""
|
|
827
|
+
If true, a sprite is updated by q5play before each physics update.
|
|
828
|
+
|
|
829
|
+
Default: `true`
|
|
830
|
+
"""
|
|
831
|
+
...
|
|
832
|
+
|
|
833
|
+
@autoUpdate.setter
|
|
834
|
+
def autoUpdate(self, val: bool) -> None: ...
|
|
835
|
+
|
|
836
|
+
@property
|
|
837
|
+
def autoDraw(self) -> bool:
|
|
838
|
+
"""
|
|
839
|
+
If true, a sprite is drawn by q5play after each physics update.
|
|
840
|
+
|
|
841
|
+
Default: `true`
|
|
842
|
+
"""
|
|
843
|
+
...
|
|
844
|
+
|
|
845
|
+
@autoDraw.setter
|
|
846
|
+
def autoDraw(self, val: bool) -> None: ...
|
|
847
|
+
|
|
848
|
+
@property
|
|
849
|
+
def allowSleeping(self) -> bool:
|
|
850
|
+
"""
|
|
851
|
+
Controls the ability for a sprite to "sleep".
|
|
852
|
+
|
|
853
|
+
"Sleeping" sprites are not included in the physics simulation, a
|
|
854
|
+
sprite starts "sleeping" when it stops moving and doesn't collide
|
|
855
|
+
with anything that it wasn't already colliding with.
|
|
856
|
+
|
|
857
|
+
Default: `true`
|
|
858
|
+
"""
|
|
859
|
+
...
|
|
860
|
+
|
|
861
|
+
@allowSleeping.setter
|
|
862
|
+
def allowSleeping(self, val: bool) -> None: ...
|
|
863
|
+
|
|
864
|
+
@property
|
|
865
|
+
def bounciness(self) -> float:
|
|
866
|
+
"""
|
|
867
|
+
The bounciness of the sprite's physics body.
|
|
868
|
+
|
|
869
|
+
Default: `0.2`
|
|
870
|
+
"""
|
|
871
|
+
...
|
|
872
|
+
|
|
873
|
+
@bounciness.setter
|
|
874
|
+
def bounciness(self, val: float) -> None: ...
|
|
875
|
+
|
|
876
|
+
@property
|
|
877
|
+
def rotationSpeed(self) -> float:
|
|
878
|
+
"""
|
|
879
|
+
The speed of the sprite's rotation in angles per frame.
|
|
880
|
+
|
|
881
|
+
Default: `0`
|
|
882
|
+
"""
|
|
883
|
+
...
|
|
884
|
+
|
|
885
|
+
@rotationSpeed.setter
|
|
886
|
+
def rotationSpeed(self, val: float) -> None: ...
|
|
887
|
+
|
|
888
|
+
@property
|
|
889
|
+
def color(self) -> Color:
|
|
890
|
+
"""
|
|
891
|
+
The sprite's current fill color.
|
|
892
|
+
|
|
893
|
+
By default sprites get a random color.
|
|
894
|
+
"""
|
|
895
|
+
...
|
|
896
|
+
|
|
897
|
+
@color.setter
|
|
898
|
+
def color(self, val: Color) -> None: ...
|
|
899
|
+
|
|
900
|
+
@property
|
|
901
|
+
def colour(self) -> Color:
|
|
902
|
+
"""
|
|
903
|
+
The sprite's current fill colour.
|
|
904
|
+
|
|
905
|
+
By default sprites get a random color.
|
|
906
|
+
"""
|
|
907
|
+
...
|
|
908
|
+
|
|
909
|
+
@colour.setter
|
|
910
|
+
def colour(self, val: Color) -> None: ...
|
|
911
|
+
|
|
912
|
+
@property
|
|
913
|
+
def fill(self) -> Color:
|
|
914
|
+
"""
|
|
915
|
+
The sprite's current fill color.
|
|
916
|
+
|
|
917
|
+
By default sprites get a random color.
|
|
918
|
+
"""
|
|
919
|
+
...
|
|
920
|
+
|
|
921
|
+
@fill.setter
|
|
922
|
+
def fill(self, val: Color) -> None: ...
|
|
923
|
+
|
|
924
|
+
@property
|
|
925
|
+
def stroke(self) -> Color:
|
|
926
|
+
"""The sprite's stroke color."""
|
|
927
|
+
...
|
|
928
|
+
|
|
929
|
+
@stroke.setter
|
|
930
|
+
def stroke(self, val: Color) -> None: ...
|
|
931
|
+
|
|
932
|
+
@property
|
|
933
|
+
def strokeWeight(self) -> float:
|
|
934
|
+
"""The sprite's stroke weight, the thickness of its outline."""
|
|
935
|
+
...
|
|
936
|
+
|
|
937
|
+
@strokeWeight.setter
|
|
938
|
+
def strokeWeight(self, val: float) -> None: ...
|
|
939
|
+
|
|
940
|
+
@property
|
|
941
|
+
def textFill(self) -> Color:
|
|
942
|
+
"""
|
|
943
|
+
The sprite's text fill color. Black by default.
|
|
944
|
+
|
|
945
|
+
Default: `black (#000000)`
|
|
946
|
+
"""
|
|
947
|
+
...
|
|
948
|
+
|
|
949
|
+
@textFill.setter
|
|
950
|
+
def textFill(self, val: Color) -> None: ...
|
|
951
|
+
|
|
952
|
+
@property
|
|
953
|
+
def textSize(self) -> float:
|
|
954
|
+
"""The sprite's text size, the sketch's current textSize by default."""
|
|
955
|
+
...
|
|
956
|
+
|
|
957
|
+
@textSize.setter
|
|
958
|
+
def textSize(self, val: float) -> None: ...
|
|
959
|
+
|
|
960
|
+
@property
|
|
961
|
+
def textStroke(self) -> Color:
|
|
962
|
+
"""
|
|
963
|
+
The sprite's text stroke color.
|
|
964
|
+
No stroke by default, does not inherit from the sketch's stroke color.
|
|
965
|
+
|
|
966
|
+
Default: `undefined`
|
|
967
|
+
"""
|
|
968
|
+
...
|
|
969
|
+
|
|
970
|
+
@textStroke.setter
|
|
971
|
+
def textStroke(self, val: Color) -> None: ...
|
|
972
|
+
|
|
973
|
+
@property
|
|
974
|
+
def textStrokeWeight(self) -> float:
|
|
975
|
+
"""
|
|
976
|
+
The sprite's text stroke weight, the thickness of its outline.
|
|
977
|
+
No stroke by default, does not inherit from the sketch's stroke weight.
|
|
978
|
+
|
|
979
|
+
Default: `undefined`
|
|
980
|
+
"""
|
|
981
|
+
...
|
|
982
|
+
|
|
983
|
+
@textStrokeWeight.setter
|
|
984
|
+
def textStrokeWeight(self, val: float) -> None: ...
|
|
985
|
+
|
|
986
|
+
@property
|
|
987
|
+
def tile(self) -> str:
|
|
988
|
+
"""The tile character that represents the sprite in a tile map."""
|
|
989
|
+
...
|
|
990
|
+
|
|
991
|
+
@tile.setter
|
|
992
|
+
def tile(self, val: str) -> None: ...
|
|
993
|
+
|
|
994
|
+
@property
|
|
995
|
+
def bearing(self) -> float:
|
|
996
|
+
"""
|
|
997
|
+
A bearing indicates the direction that needs to be followed to
|
|
998
|
+
reach a destination.
|
|
999
|
+
|
|
1000
|
+
Setting a sprite's bearing doesn't do anything by itself.
|
|
1001
|
+
You can apply a force to the sprite at its bearing angle
|
|
1002
|
+
using the `applyForce` function.
|
|
1003
|
+
"""
|
|
1004
|
+
...
|
|
1005
|
+
|
|
1006
|
+
@bearing.setter
|
|
1007
|
+
def bearing(self, val: float) -> None: ...
|
|
1008
|
+
|
|
1009
|
+
@property
|
|
1010
|
+
def debug(self) -> bool:
|
|
1011
|
+
"""
|
|
1012
|
+
If true, outlines of the sprite's colliders and sensors will be drawn.
|
|
1013
|
+
|
|
1014
|
+
Default: `false`
|
|
1015
|
+
"""
|
|
1016
|
+
...
|
|
1017
|
+
|
|
1018
|
+
@debug.setter
|
|
1019
|
+
def debug(self, val: bool) -> None: ...
|
|
1020
|
+
|
|
1021
|
+
@property
|
|
1022
|
+
def density(self) -> float:
|
|
1023
|
+
"""
|
|
1024
|
+
The density of the sprite's physics body.
|
|
1025
|
+
|
|
1026
|
+
Default: `1`
|
|
1027
|
+
"""
|
|
1028
|
+
...
|
|
1029
|
+
|
|
1030
|
+
@density.setter
|
|
1031
|
+
def density(self, val: float) -> None: ...
|
|
1032
|
+
|
|
1033
|
+
@property
|
|
1034
|
+
def direction(self) -> float:
|
|
1035
|
+
"""
|
|
1036
|
+
The angle of the sprite's movement.
|
|
1037
|
+
|
|
1038
|
+
Can be set with directional strings like "up", "down", "left", "right",
|
|
1039
|
+
"upRight", "upLeft", "downRight", and "downLeft". The setter's input parser ignores
|
|
1040
|
+
capitalization, spaces, underscores, dashes, and cardinal direction word order.
|
|
1041
|
+
|
|
1042
|
+
Default: `0 ("right")`
|
|
1043
|
+
"""
|
|
1044
|
+
...
|
|
1045
|
+
|
|
1046
|
+
@direction.setter
|
|
1047
|
+
def direction(self, val: float | str) -> None: ...
|
|
1048
|
+
|
|
1049
|
+
@property
|
|
1050
|
+
def drag(self) -> float:
|
|
1051
|
+
"""
|
|
1052
|
+
The amount of resistance a sprite has to being moved.
|
|
1053
|
+
|
|
1054
|
+
Default: `0`
|
|
1055
|
+
"""
|
|
1056
|
+
...
|
|
1057
|
+
|
|
1058
|
+
@drag.setter
|
|
1059
|
+
def drag(self, val: float) -> None: ...
|
|
1060
|
+
|
|
1061
|
+
@property
|
|
1062
|
+
def draw(self) -> Callable[..., Any]:
|
|
1063
|
+
"""
|
|
1064
|
+
Displays the sprite.
|
|
1065
|
+
|
|
1066
|
+
This function is called automatically at the end of each
|
|
1067
|
+
sketch `draw` function call but it can also be run
|
|
1068
|
+
by users to customize the order sprites are drawn in relation
|
|
1069
|
+
to other stuff drawn on the canvas. Also see the sprite.layer
|
|
1070
|
+
property.
|
|
1071
|
+
|
|
1072
|
+
A sprite's draw function can be overridden with a
|
|
1073
|
+
custom draw function, inside this function (0, 0) is the center of
|
|
1074
|
+
the sprite.
|
|
1075
|
+
"""
|
|
1076
|
+
...
|
|
1077
|
+
|
|
1078
|
+
@draw.setter
|
|
1079
|
+
def draw(self, val: Callable[..., Any]) -> None: ...
|
|
1080
|
+
|
|
1081
|
+
@property
|
|
1082
|
+
def friction(self) -> float:
|
|
1083
|
+
"""
|
|
1084
|
+
The amount the sprite's colliders resist moving
|
|
1085
|
+
when rubbing against other colliders.
|
|
1086
|
+
|
|
1087
|
+
Default: `0.5`
|
|
1088
|
+
"""
|
|
1089
|
+
...
|
|
1090
|
+
|
|
1091
|
+
@friction.setter
|
|
1092
|
+
def friction(self, val: float) -> None: ...
|
|
1093
|
+
|
|
1094
|
+
@property
|
|
1095
|
+
def heading(self) -> str:
|
|
1096
|
+
"""
|
|
1097
|
+
The sprite's heading. This is a string that can be set to
|
|
1098
|
+
"up", "down", "left", "right", "upRight", "upLeft", "downRight"
|
|
1099
|
+
|
|
1100
|
+
The setter's input parser ignores capitalization, spaces,
|
|
1101
|
+
underscores, dashes, and cardinal direction word order.
|
|
1102
|
+
|
|
1103
|
+
Default: `undefined`
|
|
1104
|
+
"""
|
|
1105
|
+
...
|
|
1106
|
+
|
|
1107
|
+
@heading.setter
|
|
1108
|
+
def heading(self, val: str) -> None: ...
|
|
1109
|
+
|
|
1110
|
+
@property
|
|
1111
|
+
def isSuperFast(self) -> bool:
|
|
1112
|
+
"""
|
|
1113
|
+
Set this to true if the sprite goes really fast to prevent
|
|
1114
|
+
inaccurate physics simulation.
|
|
1115
|
+
|
|
1116
|
+
Default: `false`
|
|
1117
|
+
"""
|
|
1118
|
+
...
|
|
1119
|
+
|
|
1120
|
+
@isSuperFast.setter
|
|
1121
|
+
def isSuperFast(self, val: bool) -> None: ...
|
|
1122
|
+
|
|
1123
|
+
@property
|
|
1124
|
+
def layer(self) -> float:
|
|
1125
|
+
"""
|
|
1126
|
+
Sprites with the highest layer value get drawn first.
|
|
1127
|
+
|
|
1128
|
+
By default sprites are drawn in the order they were created in.
|
|
1129
|
+
"""
|
|
1130
|
+
...
|
|
1131
|
+
|
|
1132
|
+
@layer.setter
|
|
1133
|
+
def layer(self, val: float) -> None: ...
|
|
1134
|
+
|
|
1135
|
+
@property
|
|
1136
|
+
def life(self) -> float:
|
|
1137
|
+
"""
|
|
1138
|
+
When the physics simulation is progressed in `world.physicsUpdate`,
|
|
1139
|
+
each sprite's life is decreased by `world.timeScale`.
|
|
1140
|
+
|
|
1141
|
+
If life becomes less than or equal to 0, the sprite will
|
|
1142
|
+
be removed.
|
|
1143
|
+
|
|
1144
|
+
Default: `Infinity`
|
|
1145
|
+
"""
|
|
1146
|
+
...
|
|
1147
|
+
|
|
1148
|
+
@life.setter
|
|
1149
|
+
def life(self, val: float) -> None: ...
|
|
1150
|
+
|
|
1151
|
+
@property
|
|
1152
|
+
def opacity(self) -> float:
|
|
1153
|
+
"""
|
|
1154
|
+
The sprite's opacity. 0 is transparent, 1 is opaque.
|
|
1155
|
+
|
|
1156
|
+
Default: `1`
|
|
1157
|
+
"""
|
|
1158
|
+
...
|
|
1159
|
+
|
|
1160
|
+
@opacity.setter
|
|
1161
|
+
def opacity(self, val: float) -> None: ...
|
|
1162
|
+
|
|
1163
|
+
@property
|
|
1164
|
+
def previousX(self) -> float:
|
|
1165
|
+
"""
|
|
1166
|
+
The sprite's x position on the previous frame.
|
|
1167
|
+
Alias for sprite.prevX.
|
|
1168
|
+
"""
|
|
1169
|
+
...
|
|
1170
|
+
|
|
1171
|
+
@property
|
|
1172
|
+
def previousY(self) -> float:
|
|
1173
|
+
"""
|
|
1174
|
+
The sprite's y position on the previous frame.
|
|
1175
|
+
Alias for sprite.prevY.
|
|
1176
|
+
"""
|
|
1177
|
+
...
|
|
1178
|
+
|
|
1179
|
+
@property
|
|
1180
|
+
def previousRotation(self) -> float:
|
|
1181
|
+
"""
|
|
1182
|
+
The sprite's rotation on the previous frame.
|
|
1183
|
+
Alias for sprite.prevRotation.
|
|
1184
|
+
"""
|
|
1185
|
+
...
|
|
1186
|
+
|
|
1187
|
+
@property
|
|
1188
|
+
def pixelPerfect(self) -> bool:
|
|
1189
|
+
"""
|
|
1190
|
+
If true, q5play will draw sprites at integer pixel precision.
|
|
1191
|
+
|
|
1192
|
+
This is useful for making retro games.
|
|
1193
|
+
|
|
1194
|
+
By default q5play draws sprites with subpixel rendering.
|
|
1195
|
+
|
|
1196
|
+
Default: `false`
|
|
1197
|
+
"""
|
|
1198
|
+
...
|
|
1199
|
+
|
|
1200
|
+
@pixelPerfect.setter
|
|
1201
|
+
def pixelPerfect(self, val: bool) -> None: ...
|
|
1202
|
+
|
|
1203
|
+
@property
|
|
1204
|
+
def deleted(self) -> bool:
|
|
1205
|
+
"""
|
|
1206
|
+
If the sprite has been deleted from the world.
|
|
1207
|
+
|
|
1208
|
+
Default: `false`
|
|
1209
|
+
"""
|
|
1210
|
+
...
|
|
1211
|
+
|
|
1212
|
+
@deleted.setter
|
|
1213
|
+
def deleted(self, val: bool) -> None: ...
|
|
1214
|
+
|
|
1215
|
+
@property
|
|
1216
|
+
def rollingResistance(self) -> float:
|
|
1217
|
+
"""
|
|
1218
|
+
Simulates friction that slows down a sprite rolling on another sprite,
|
|
1219
|
+
like a soccer ball rolling to a stop on high grass.
|
|
1220
|
+
|
|
1221
|
+
Default: `0`
|
|
1222
|
+
"""
|
|
1223
|
+
...
|
|
1224
|
+
|
|
1225
|
+
@rollingResistance.setter
|
|
1226
|
+
def rollingResistance(self, val: float) -> None: ...
|
|
1227
|
+
|
|
1228
|
+
@property
|
|
1229
|
+
def rotationDrag(self) -> float:
|
|
1230
|
+
"""
|
|
1231
|
+
The amount the sprite resists rotating.
|
|
1232
|
+
|
|
1233
|
+
Default: `0`
|
|
1234
|
+
"""
|
|
1235
|
+
...
|
|
1236
|
+
|
|
1237
|
+
@rotationDrag.setter
|
|
1238
|
+
def rotationDrag(self, val: float) -> None: ...
|
|
1239
|
+
|
|
1240
|
+
@property
|
|
1241
|
+
def rotationLock(self) -> bool:
|
|
1242
|
+
"""
|
|
1243
|
+
If true, the sprite can not rotate.
|
|
1244
|
+
|
|
1245
|
+
Default: `false`
|
|
1246
|
+
"""
|
|
1247
|
+
...
|
|
1248
|
+
|
|
1249
|
+
@rotationLock.setter
|
|
1250
|
+
def rotationLock(self, val: bool) -> None: ...
|
|
1251
|
+
|
|
1252
|
+
@property
|
|
1253
|
+
def scale(self) -> float | dict:
|
|
1254
|
+
"""
|
|
1255
|
+
Horizontal and vertical scale of the sprite.
|
|
1256
|
+
|
|
1257
|
+
Components can be negative to flip/mirror the sprite on an axis.
|
|
1258
|
+
|
|
1259
|
+
The `valueOf` function for `sprite.scale` returns the scale as a
|
|
1260
|
+
number. This enables users to do things like `sprite.scale *= 2`
|
|
1261
|
+
to double the sprite's scale.
|
|
1262
|
+
|
|
1263
|
+
Default: `{x: 1, y: 1}`
|
|
1264
|
+
"""
|
|
1265
|
+
...
|
|
1266
|
+
|
|
1267
|
+
@scale.setter
|
|
1268
|
+
def scale(self, val: float | list | dict) -> None: ...
|
|
1269
|
+
|
|
1270
|
+
def scaleBy(self, x: float, y: float = ...) -> None:
|
|
1271
|
+
"""
|
|
1272
|
+
Scales the the sprite.
|
|
1273
|
+
|
|
1274
|
+
Args:
|
|
1275
|
+
x: scaleX or uniform scale factor
|
|
1276
|
+
y: scaleY
|
|
1277
|
+
"""
|
|
1278
|
+
...
|
|
1279
|
+
|
|
1280
|
+
@property
|
|
1281
|
+
def sleeping(self) -> bool:
|
|
1282
|
+
"""
|
|
1283
|
+
Wake a sprite up or put it to sleep.
|
|
1284
|
+
|
|
1285
|
+
"Sleeping" sprites are not included in the physics simulation, a
|
|
1286
|
+
sprite starts "sleeping" when it stops moving and doesn't collide
|
|
1287
|
+
with anything that it wasn't already colliding with.
|
|
1288
|
+
|
|
1289
|
+
Default: `true`
|
|
1290
|
+
"""
|
|
1291
|
+
...
|
|
1292
|
+
|
|
1293
|
+
@sleeping.setter
|
|
1294
|
+
def sleeping(self, val: bool) -> None: ...
|
|
1295
|
+
|
|
1296
|
+
@property
|
|
1297
|
+
def sleepThreshold(self) -> float:
|
|
1298
|
+
"""
|
|
1299
|
+
The minimum speed (in m/s) at which the sprite must be moving
|
|
1300
|
+
before it is considered awake.
|
|
1301
|
+
"""
|
|
1302
|
+
...
|
|
1303
|
+
|
|
1304
|
+
@sleepThreshold.setter
|
|
1305
|
+
def sleepThreshold(self, val: float) -> None: ...
|
|
1306
|
+
|
|
1307
|
+
@property
|
|
1308
|
+
def speed(self) -> float:
|
|
1309
|
+
"""
|
|
1310
|
+
The sprite's speed.
|
|
1311
|
+
|
|
1312
|
+
Setting speed to a negative value will make the sprite move
|
|
1313
|
+
180 degrees opposite of its current direction angle.
|
|
1314
|
+
|
|
1315
|
+
Default: `0`
|
|
1316
|
+
"""
|
|
1317
|
+
...
|
|
1318
|
+
|
|
1319
|
+
@speed.setter
|
|
1320
|
+
def speed(self, val: float) -> None: ...
|
|
1321
|
+
|
|
1322
|
+
def setSpeedAndDirection(self, speed: float, direction: float) -> None:
|
|
1323
|
+
"""Efficiently sets the sprite's speed and direction at the same time."""
|
|
1324
|
+
...
|
|
1325
|
+
|
|
1326
|
+
@property
|
|
1327
|
+
def surfaceSpeed(self) -> float:
|
|
1328
|
+
"""
|
|
1329
|
+
The sprite's speed along the surface of its collider(s),
|
|
1330
|
+
like a conveyor belt.
|
|
1331
|
+
|
|
1332
|
+
Default: `0`
|
|
1333
|
+
"""
|
|
1334
|
+
...
|
|
1335
|
+
|
|
1336
|
+
@surfaceSpeed.setter
|
|
1337
|
+
def surfaceSpeed(self, val: float) -> None: ...
|
|
1338
|
+
|
|
1339
|
+
@property
|
|
1340
|
+
def tint(self) -> Color:
|
|
1341
|
+
"""
|
|
1342
|
+
Tint color applied to the sprite when drawn.
|
|
1343
|
+
|
|
1344
|
+
Note that this is not good for performance, you should probably
|
|
1345
|
+
pre-render the effect if you want to use it a lot.
|
|
1346
|
+
|
|
1347
|
+
Default: `undefined`
|
|
1348
|
+
"""
|
|
1349
|
+
...
|
|
1350
|
+
|
|
1351
|
+
@tint.setter
|
|
1352
|
+
def tint(self, val: Color) -> None: ...
|
|
1353
|
+
|
|
1354
|
+
@property
|
|
1355
|
+
def visible(self) -> bool:
|
|
1356
|
+
"""
|
|
1357
|
+
If true the sprite is shown, if set to false the sprite is hidden.
|
|
1358
|
+
|
|
1359
|
+
Becomes null when the sprite is off screen but will be drawn and
|
|
1360
|
+
set to true again if it goes back on screen.
|
|
1361
|
+
|
|
1362
|
+
Default: `true`
|
|
1363
|
+
"""
|
|
1364
|
+
...
|
|
1365
|
+
|
|
1366
|
+
@visible.setter
|
|
1367
|
+
def visible(self, val: bool) -> None: ...
|
|
1368
|
+
|
|
1369
|
+
@property
|
|
1370
|
+
def pos(self) -> dict:
|
|
1371
|
+
"""
|
|
1372
|
+
Gets the sprite's position as a readonly object {x, y} which
|
|
1373
|
+
won't be updated if the sprite moves. Useful for saving
|
|
1374
|
+
the sprite's position at a specific moment in time.
|
|
1375
|
+
"""
|
|
1376
|
+
...
|
|
1377
|
+
|
|
1378
|
+
@pos.setter
|
|
1379
|
+
def pos(self, val: list[float] | dict) -> None: ...
|
|
1380
|
+
|
|
1381
|
+
@property
|
|
1382
|
+
def position(self) -> Vector:
|
|
1383
|
+
"""The sprite's position vector."""
|
|
1384
|
+
...
|
|
1385
|
+
|
|
1386
|
+
@position.setter
|
|
1387
|
+
def position(self, val: list[float] | dict) -> None: ...
|
|
1388
|
+
|
|
1389
|
+
@property
|
|
1390
|
+
def canvasPos(self) -> Any:
|
|
1391
|
+
"""The sprite's absolute position on the canvas."""
|
|
1392
|
+
...
|
|
1393
|
+
|
|
1394
|
+
@property
|
|
1395
|
+
def hw(self) -> float:
|
|
1396
|
+
"""Half the width of the sprite."""
|
|
1397
|
+
...
|
|
1398
|
+
|
|
1399
|
+
@hw.setter
|
|
1400
|
+
def hw(self, val: float) -> None: ...
|
|
1401
|
+
|
|
1402
|
+
@property
|
|
1403
|
+
def width(self) -> float:
|
|
1404
|
+
"""The width of the sprite."""
|
|
1405
|
+
...
|
|
1406
|
+
|
|
1407
|
+
@width.setter
|
|
1408
|
+
def width(self, val: float) -> None: ...
|
|
1409
|
+
|
|
1410
|
+
@property
|
|
1411
|
+
def halfWidth(self) -> float:
|
|
1412
|
+
"""Half the width of the sprite."""
|
|
1413
|
+
...
|
|
1414
|
+
|
|
1415
|
+
@halfWidth.setter
|
|
1416
|
+
def halfWidth(self, val: float) -> None: ...
|
|
1417
|
+
|
|
1418
|
+
@property
|
|
1419
|
+
def hh(self) -> float:
|
|
1420
|
+
"""Half the height of the sprite."""
|
|
1421
|
+
...
|
|
1422
|
+
|
|
1423
|
+
@hh.setter
|
|
1424
|
+
def hh(self, val: float) -> None: ...
|
|
1425
|
+
|
|
1426
|
+
@property
|
|
1427
|
+
def height(self) -> float:
|
|
1428
|
+
"""The height of the sprite."""
|
|
1429
|
+
...
|
|
1430
|
+
|
|
1431
|
+
@height.setter
|
|
1432
|
+
def height(self, val: float) -> None: ...
|
|
1433
|
+
|
|
1434
|
+
@property
|
|
1435
|
+
def halfHeight(self) -> float:
|
|
1436
|
+
"""Half the height of the sprite."""
|
|
1437
|
+
...
|
|
1438
|
+
|
|
1439
|
+
@halfHeight.setter
|
|
1440
|
+
def halfHeight(self, val: float) -> None: ...
|
|
1441
|
+
|
|
1442
|
+
@property
|
|
1443
|
+
def d(self) -> float:
|
|
1444
|
+
"""The diameter of a circular sprite."""
|
|
1445
|
+
...
|
|
1446
|
+
|
|
1447
|
+
@d.setter
|
|
1448
|
+
def d(self, val: float) -> None: ...
|
|
1449
|
+
|
|
1450
|
+
@property
|
|
1451
|
+
def diameter(self) -> float:
|
|
1452
|
+
"""The diameter of a circular sprite."""
|
|
1453
|
+
...
|
|
1454
|
+
|
|
1455
|
+
@diameter.setter
|
|
1456
|
+
def diameter(self, val: float) -> None: ...
|
|
1457
|
+
|
|
1458
|
+
@property
|
|
1459
|
+
def r(self) -> float:
|
|
1460
|
+
"""The radius of a circular sprite."""
|
|
1461
|
+
...
|
|
1462
|
+
|
|
1463
|
+
@r.setter
|
|
1464
|
+
def r(self, val: float) -> None: ...
|
|
1465
|
+
|
|
1466
|
+
@property
|
|
1467
|
+
def radius(self) -> float:
|
|
1468
|
+
"""The radius of a circular sprite."""
|
|
1469
|
+
...
|
|
1470
|
+
|
|
1471
|
+
@radius.setter
|
|
1472
|
+
def radius(self, val: float) -> None: ...
|
|
1473
|
+
|
|
1474
|
+
@property
|
|
1475
|
+
def update(self) -> Callable[..., Any]:
|
|
1476
|
+
"""
|
|
1477
|
+
Runs before each physics update by default.
|
|
1478
|
+
|
|
1479
|
+
Set this to a custom function that handles input, directs sprite movement,
|
|
1480
|
+
and performs other tasks that should run before the physics update.
|
|
1481
|
+
|
|
1482
|
+
Optionally, users can run this function manually in q5play's `update`
|
|
1483
|
+
function.
|
|
1484
|
+
"""
|
|
1485
|
+
...
|
|
1486
|
+
|
|
1487
|
+
@update.setter
|
|
1488
|
+
def update(self, val: Callable[..., Any]) -> None: ...
|
|
1489
|
+
|
|
1490
|
+
@property
|
|
1491
|
+
def vel(self) -> Vector:
|
|
1492
|
+
"""
|
|
1493
|
+
The sprite's velocity vector {x, y}
|
|
1494
|
+
|
|
1495
|
+
Default: `{x: 0, y: 0}`
|
|
1496
|
+
"""
|
|
1497
|
+
...
|
|
1498
|
+
|
|
1499
|
+
@vel.setter
|
|
1500
|
+
def vel(self, val: list | dict | Vector) -> None: ...
|
|
1501
|
+
|
|
1502
|
+
@property
|
|
1503
|
+
def velocity(self) -> Vector:
|
|
1504
|
+
"""
|
|
1505
|
+
The sprite's velocity vector {x, y}
|
|
1506
|
+
|
|
1507
|
+
Default: `{x: 0, y: 0}`
|
|
1508
|
+
"""
|
|
1509
|
+
...
|
|
1510
|
+
|
|
1511
|
+
@velocity.setter
|
|
1512
|
+
def velocity(self, val: list | dict | Vector) -> None: ...
|
|
1513
|
+
|
|
1514
|
+
@property
|
|
1515
|
+
def grabbable(self) -> bool:
|
|
1516
|
+
"""Whether the sprite can be grabbed by a pointer."""
|
|
1517
|
+
...
|
|
1518
|
+
|
|
1519
|
+
@grabbable.setter
|
|
1520
|
+
def grabbable(self, val: bool) -> None: ...
|
|
1521
|
+
|
|
1522
|
+
@property
|
|
1523
|
+
def gravityScale(self) -> float:
|
|
1524
|
+
"""
|
|
1525
|
+
A ratio that defines how much the sprite is affected by gravity.
|
|
1526
|
+
|
|
1527
|
+
Default: `1`
|
|
1528
|
+
"""
|
|
1529
|
+
...
|
|
1530
|
+
|
|
1531
|
+
@gravityScale.setter
|
|
1532
|
+
def gravityScale(self, val: float) -> None: ...
|
|
1533
|
+
|
|
1534
|
+
@overload
|
|
1535
|
+
def applyForce(self, amount: float, origin: dict = ...) -> None:
|
|
1536
|
+
"""
|
|
1537
|
+
Applies a force magnitude at the sprite's current bearing.
|
|
1538
|
+
|
|
1539
|
+
Args:
|
|
1540
|
+
amount: force magnitude
|
|
1541
|
+
origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1542
|
+
"""
|
|
1543
|
+
...
|
|
1544
|
+
|
|
1545
|
+
@overload
|
|
1546
|
+
def applyForce(self, force: list[dict | float], origin: dict = ...) -> None:
|
|
1547
|
+
"""
|
|
1548
|
+
Applies a force vector to the sprite.
|
|
1549
|
+
|
|
1550
|
+
Args:
|
|
1551
|
+
force: force vector as an object with `x` and `y` properties or array of [x, y]
|
|
1552
|
+
origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1553
|
+
"""
|
|
1554
|
+
...
|
|
1555
|
+
|
|
1556
|
+
def applyForce(self, force: list[dict | float], origin: dict = ...) -> None:
|
|
1557
|
+
...
|
|
1558
|
+
|
|
1559
|
+
@overload
|
|
1560
|
+
def applyForceScaled(self, amount: float, origin: dict = ...) -> None:
|
|
1561
|
+
"""
|
|
1562
|
+
Applies a force scaled to the sprite's mass using a magnitude.
|
|
1563
|
+
|
|
1564
|
+
Args:
|
|
1565
|
+
amount: force magnitude
|
|
1566
|
+
origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1567
|
+
"""
|
|
1568
|
+
...
|
|
1569
|
+
|
|
1570
|
+
@overload
|
|
1571
|
+
def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
|
|
1572
|
+
"""
|
|
1573
|
+
Applies a force scaled to the sprite's mass using a vector.
|
|
1574
|
+
|
|
1575
|
+
Args:
|
|
1576
|
+
force: force vector as an object with `x` and `y` properties
|
|
1577
|
+
origin: point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1578
|
+
"""
|
|
1579
|
+
...
|
|
1580
|
+
|
|
1581
|
+
def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
|
|
1582
|
+
...
|
|
1583
|
+
|
|
1584
|
+
def applyWind(self, strength: float, angle: float, drag: float = ..., lift: float = ...) -> None:
|
|
1585
|
+
"""
|
|
1586
|
+
Applies wind force to the sprite.
|
|
1587
|
+
|
|
1588
|
+
Args:
|
|
1589
|
+
strength: the strength of the wind
|
|
1590
|
+
angle: the angle the wind is blowing at
|
|
1591
|
+
drag: the force that opposes the relative velocity
|
|
1592
|
+
lift: the force that is perpendicular to the relative velocity
|
|
1593
|
+
"""
|
|
1594
|
+
...
|
|
1595
|
+
|
|
1596
|
+
@overload
|
|
1597
|
+
def attractTo(self, x: float, y: float, force: float = ...) -> None:
|
|
1598
|
+
"""
|
|
1599
|
+
Applies a force to the sprite's center of mass attracting it to
|
|
1600
|
+
the given position.
|
|
1601
|
+
|
|
1602
|
+
Args:
|
|
1603
|
+
x: x coordinate
|
|
1604
|
+
y: y coordinate
|
|
1605
|
+
"""
|
|
1606
|
+
...
|
|
1607
|
+
|
|
1608
|
+
@overload
|
|
1609
|
+
def attractTo(self, pos: dict, force: float = ...) -> None:
|
|
1610
|
+
"""
|
|
1611
|
+
Applies a force to the sprite's center of mass attracting it to
|
|
1612
|
+
the given position.
|
|
1613
|
+
|
|
1614
|
+
Args:
|
|
1615
|
+
pos: object with x and y properties
|
|
1616
|
+
"""
|
|
1617
|
+
...
|
|
1618
|
+
|
|
1619
|
+
def attractTo(self, pos: dict, force: float = ...) -> None:
|
|
1620
|
+
...
|
|
1621
|
+
|
|
1622
|
+
@overload
|
|
1623
|
+
def repelFrom(self, x: float, y: float, force: float = ...) -> None:
|
|
1624
|
+
"""
|
|
1625
|
+
Applies a force to the sprite's center of mass repelling it from
|
|
1626
|
+
the given position.
|
|
1627
|
+
|
|
1628
|
+
Args:
|
|
1629
|
+
x: x coordinate
|
|
1630
|
+
y: y coordinate
|
|
1631
|
+
"""
|
|
1632
|
+
...
|
|
1633
|
+
|
|
1634
|
+
@overload
|
|
1635
|
+
def repelFrom(self, pos: dict, force: float = ...) -> None:
|
|
1636
|
+
"""
|
|
1637
|
+
Applies a force to the sprite's center of mass repelling it from
|
|
1638
|
+
the given position.
|
|
1639
|
+
|
|
1640
|
+
Args:
|
|
1641
|
+
pos: object with x and y properties
|
|
1642
|
+
"""
|
|
1643
|
+
...
|
|
1644
|
+
|
|
1645
|
+
def repelFrom(self, pos: dict, force: float = ...) -> None:
|
|
1646
|
+
...
|
|
1647
|
+
|
|
1648
|
+
def applyTorque(self, torque: Any) -> None:
|
|
1649
|
+
"""
|
|
1650
|
+
Apply a torque on the sprite's physics body.
|
|
1651
|
+
Torque is the force that causes rotation.
|
|
1652
|
+
A positive torque will rotate the sprite clockwise.
|
|
1653
|
+
A negative torque will rotate the sprite counter-clockwise.
|
|
1654
|
+
|
|
1655
|
+
This function is the rotational equivalent of applyForce().
|
|
1656
|
+
It will not imperatively set the sprite's rotation.
|
|
1657
|
+
"""
|
|
1658
|
+
...
|
|
1659
|
+
|
|
1660
|
+
@overload
|
|
1661
|
+
def moveTo(self, x: float | None, y: float | None, speed: float = ...) -> Awaitable[bool]:
|
|
1662
|
+
"""
|
|
1663
|
+
Attempts to move the sprite to a destination at a constant speed
|
|
1664
|
+
and stops the sprite if it reaches the destination.
|
|
1665
|
+
|
|
1666
|
+
The destination check is deferred until the sprite is estimated to be
|
|
1667
|
+
at the target position, based on `world.physicsTime`.
|
|
1668
|
+
|
|
1669
|
+
Args:
|
|
1670
|
+
x: destination x, or `null` to only move on the y-axis
|
|
1671
|
+
y: destination y, or `null` to only move on the x-axis
|
|
1672
|
+
speed: movement speed in pixels per frame, defaults to the sprite's current speed or 1
|
|
1673
|
+
|
|
1674
|
+
Returns:
|
|
1675
|
+
a lazy thenable that resolves `true` if the sprite reached the destination, or `false` if it didn't.
|
|
1676
|
+
"""
|
|
1677
|
+
...
|
|
1678
|
+
|
|
1679
|
+
@overload
|
|
1680
|
+
def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
|
|
1681
|
+
"""
|
|
1682
|
+
Attempts to move the sprite to a destination at a constant speed
|
|
1683
|
+
and stops the sprite if it reaches the destination.
|
|
1684
|
+
|
|
1685
|
+
Args:
|
|
1686
|
+
pos: destination object with x and y properties
|
|
1687
|
+
speed: movement speed in pixels per frame, defaults to the sprite's current speed or 1
|
|
1688
|
+
|
|
1689
|
+
Returns:
|
|
1690
|
+
a lazy thenable that resolves `true` if the sprite reached the destination, or `false` if it didn't.
|
|
1691
|
+
"""
|
|
1692
|
+
...
|
|
1693
|
+
|
|
1694
|
+
def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
|
|
1695
|
+
...
|
|
1696
|
+
|
|
1697
|
+
@overload
|
|
1698
|
+
def moveTowards(self, x: float | None, y: float | None, tracking: float = ...) -> None:
|
|
1699
|
+
"""
|
|
1700
|
+
Moves the sprite towards a position at a percentage of the distance
|
|
1701
|
+
between itself and the destination.
|
|
1702
|
+
|
|
1703
|
+
Args:
|
|
1704
|
+
x: destination x, or `null` to only move on the y-axis
|
|
1705
|
+
y: destination y, or `null` to only move on the x-axis
|
|
1706
|
+
tracking: percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
|
|
1707
|
+
"""
|
|
1708
|
+
...
|
|
1709
|
+
|
|
1710
|
+
@overload
|
|
1711
|
+
def moveTowards(self, pos: dict, tracking: float = ...) -> None:
|
|
1712
|
+
"""
|
|
1713
|
+
Moves the sprite towards a position at a percentage of the distance
|
|
1714
|
+
between itself and the destination.
|
|
1715
|
+
|
|
1716
|
+
Args:
|
|
1717
|
+
pos: destination object with x and y properties
|
|
1718
|
+
tracking: percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
|
|
1719
|
+
"""
|
|
1720
|
+
...
|
|
1721
|
+
|
|
1722
|
+
def moveTowards(self, pos: dict, tracking: float = ...) -> None:
|
|
1723
|
+
...
|
|
1724
|
+
|
|
1725
|
+
@overload
|
|
1726
|
+
def rotateTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
|
|
1727
|
+
"""
|
|
1728
|
+
Rotates the sprite to a target angle at a constant speed,
|
|
1729
|
+
stopping if it arrives.
|
|
1730
|
+
|
|
1731
|
+
The destination check is deferred until the sprite is estimated to be
|
|
1732
|
+
at the target angle, based on `world.physicsTime`.
|
|
1733
|
+
|
|
1734
|
+
Args:
|
|
1735
|
+
angle: target rotation angle
|
|
1736
|
+
speed: rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1737
|
+
|
|
1738
|
+
Returns:
|
|
1739
|
+
a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
|
|
1740
|
+
"""
|
|
1741
|
+
...
|
|
1742
|
+
|
|
1743
|
+
@overload
|
|
1744
|
+
def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
1745
|
+
"""
|
|
1746
|
+
Rotates the sprite to face a position at a constant speed,
|
|
1747
|
+
stopping if it arrives.
|
|
1748
|
+
|
|
1749
|
+
Args:
|
|
1750
|
+
pos: object with x and y properties
|
|
1751
|
+
speed: rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1752
|
+
facing: rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1753
|
+
|
|
1754
|
+
Returns:
|
|
1755
|
+
a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
|
|
1756
|
+
"""
|
|
1757
|
+
...
|
|
1758
|
+
|
|
1759
|
+
def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
1760
|
+
...
|
|
1761
|
+
|
|
1762
|
+
@overload
|
|
1763
|
+
def rotateMinTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
|
|
1764
|
+
"""
|
|
1765
|
+
Rotates the sprite by the smallest angular distance to a target angle
|
|
1766
|
+
at a constant speed, stopping when it arrives.
|
|
1767
|
+
|
|
1768
|
+
Args:
|
|
1769
|
+
angle: target rotation angle
|
|
1770
|
+
speed: absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1771
|
+
|
|
1772
|
+
Returns:
|
|
1773
|
+
a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
|
|
1774
|
+
"""
|
|
1775
|
+
...
|
|
1776
|
+
|
|
1777
|
+
@overload
|
|
1778
|
+
def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
1779
|
+
"""
|
|
1780
|
+
Rotates the sprite by the smallest angular distance to face a position
|
|
1781
|
+
at a constant speed, stopping when it arrives.
|
|
1782
|
+
|
|
1783
|
+
Args:
|
|
1784
|
+
pos: object with x and y properties
|
|
1785
|
+
speed: absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1786
|
+
facing: rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1787
|
+
|
|
1788
|
+
Returns:
|
|
1789
|
+
a lazy thenable that resolves `true` if the sprite reached the target angle, or `false` if it didn't.
|
|
1790
|
+
"""
|
|
1791
|
+
...
|
|
1792
|
+
|
|
1793
|
+
def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
1794
|
+
...
|
|
1795
|
+
|
|
1796
|
+
@overload
|
|
1797
|
+
def rotateTowards(self, angle: float, tracking: float = ...) -> None:
|
|
1798
|
+
"""
|
|
1799
|
+
Rotates the sprite towards an angle.
|
|
1800
|
+
|
|
1801
|
+
Args:
|
|
1802
|
+
angle: angle in degrees
|
|
1803
|
+
tracking: percent of the distance to rotate on each frame towards the target angle, default is 0.1 (10%)
|
|
1804
|
+
"""
|
|
1805
|
+
...
|
|
1806
|
+
|
|
1807
|
+
@overload
|
|
1808
|
+
def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
|
|
1809
|
+
"""
|
|
1810
|
+
Rotates the sprite towards a position.
|
|
1811
|
+
|
|
1812
|
+
Args:
|
|
1813
|
+
pos: object with x and y properties
|
|
1814
|
+
tracking: percent of the distance to rotate on each frame towards the target position, default is 0.1 (10%)
|
|
1815
|
+
facing: rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1816
|
+
"""
|
|
1817
|
+
...
|
|
1818
|
+
|
|
1819
|
+
def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
|
|
1820
|
+
...
|
|
1821
|
+
|
|
1822
|
+
@overload
|
|
1823
|
+
def angleTo(self, x: float, y: float, facing: float = ...) -> float:
|
|
1824
|
+
"""
|
|
1825
|
+
Finds the angle from this sprite to the given position.
|
|
1826
|
+
|
|
1827
|
+
Equivalent to `atan2(y - sprite.y, x - sprite.x) + facing`.
|
|
1828
|
+
Returns the sprite's current rotation if the position is within 0.01 pixels.
|
|
1829
|
+
|
|
1830
|
+
Can be used to set the direction of a sprite so it moves toward a position.
|
|
1831
|
+
|
|
1832
|
+
Args:
|
|
1833
|
+
x: x coordinate
|
|
1834
|
+
y: y coordinate
|
|
1835
|
+
facing: offset angle added to the result, default is 0
|
|
1836
|
+
|
|
1837
|
+
Returns:
|
|
1838
|
+
angle to the position
|
|
1839
|
+
"""
|
|
1840
|
+
...
|
|
1841
|
+
|
|
1842
|
+
@overload
|
|
1843
|
+
def angleTo(self, pos: dict, facing: float = ...) -> float:
|
|
1844
|
+
"""
|
|
1845
|
+
Finds the angle from this sprite to the given position.
|
|
1846
|
+
|
|
1847
|
+
Args:
|
|
1848
|
+
pos: object with x and y properties
|
|
1849
|
+
facing: offset angle added to the result, default is 0
|
|
1850
|
+
|
|
1851
|
+
Returns:
|
|
1852
|
+
angle to the position
|
|
1853
|
+
"""
|
|
1854
|
+
...
|
|
1855
|
+
|
|
1856
|
+
def angleTo(self, pos: dict, facing: float = ...) -> float:
|
|
1857
|
+
...
|
|
1858
|
+
|
|
1859
|
+
@overload
|
|
1860
|
+
def angleDistTo(self, x: float, y: float, facing: float = ...) -> float:
|
|
1861
|
+
"""
|
|
1862
|
+
Finds the minimum angular distance the sprite would need to rotate
|
|
1863
|
+
to face a position, taking into account the sprite's current rotation.
|
|
1864
|
+
|
|
1865
|
+
Useful for `rotateTowards`-style logic where you need the signed delta
|
|
1866
|
+
rather than an absolute target angle.
|
|
1867
|
+
|
|
1868
|
+
Args:
|
|
1869
|
+
x: x coordinate
|
|
1870
|
+
y: y coordinate
|
|
1871
|
+
facing: offset angle, default is 0
|
|
1872
|
+
|
|
1873
|
+
Returns:
|
|
1874
|
+
the minimum angular distance to face the position
|
|
1875
|
+
"""
|
|
1876
|
+
...
|
|
1877
|
+
|
|
1878
|
+
@overload
|
|
1879
|
+
def angleDistTo(self, pos: dict, facing: float = ...) -> float:
|
|
1880
|
+
"""
|
|
1881
|
+
Finds the minimum angular distance the sprite would need to rotate
|
|
1882
|
+
to face a position, taking into account the sprite's current rotation.
|
|
1883
|
+
|
|
1884
|
+
Args:
|
|
1885
|
+
pos: object with x and y properties
|
|
1886
|
+
facing: offset angle, default is 0
|
|
1887
|
+
|
|
1888
|
+
Returns:
|
|
1889
|
+
the minimum angular distance to face the position
|
|
1890
|
+
"""
|
|
1891
|
+
...
|
|
1892
|
+
|
|
1893
|
+
def angleDistTo(self, pos: dict, facing: float = ...) -> float:
|
|
1894
|
+
...
|
|
1895
|
+
|
|
1896
|
+
@overload
|
|
1897
|
+
def transformTowards(self, x: float, y: float, rotation: float = ..., tracking: float = ...) -> None:
|
|
1898
|
+
"""
|
|
1899
|
+
Moves and rotates a sprite's physics body towards a target transform
|
|
1900
|
+
at a percentage of the distance on each frame.
|
|
1901
|
+
|
|
1902
|
+
Uses Box2D's `b2Body_SetTargetTransform` for maximum efficiency
|
|
1903
|
+
compared to using `moveTowards` and `rotateTowards` separately.
|
|
1904
|
+
|
|
1905
|
+
Args:
|
|
1906
|
+
x: destination x
|
|
1907
|
+
y: destination y
|
|
1908
|
+
rotation: target rotation angle
|
|
1909
|
+
tracking: percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
|
|
1910
|
+
"""
|
|
1911
|
+
...
|
|
1912
|
+
|
|
1913
|
+
@overload
|
|
1914
|
+
def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
|
|
1915
|
+
"""
|
|
1916
|
+
Moves and rotates a sprite's physics body towards a target transform
|
|
1917
|
+
at a percentage of the distance on each frame.
|
|
1918
|
+
|
|
1919
|
+
Args:
|
|
1920
|
+
pos: destination object with x and y properties
|
|
1921
|
+
rotation: target rotation angle
|
|
1922
|
+
tracking: percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
|
|
1923
|
+
"""
|
|
1924
|
+
...
|
|
1925
|
+
|
|
1926
|
+
def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
|
|
1927
|
+
...
|
|
1928
|
+
|
|
1929
|
+
def delete(self) -> None:
|
|
1930
|
+
"""
|
|
1931
|
+
Deletes the Sprite from the sketch and all the groups it
|
|
1932
|
+
belongs to.
|
|
1933
|
+
|
|
1934
|
+
When a sprite is deleted it will not be drawn or updated anymore.
|
|
1935
|
+
If it has a physics body, it will be deleted from the physics simulation.
|
|
1936
|
+
|
|
1937
|
+
There's no way to undo this operation. If you want to hide a
|
|
1938
|
+
sprite use `sprite.visible = false` instead.
|
|
1939
|
+
"""
|
|
1940
|
+
...
|
|
1941
|
+
|
|
1942
|
+
def toString(self) -> str:
|
|
1943
|
+
"""
|
|
1944
|
+
Returns the sprite's unique identifier `sprite.idNum`.
|
|
1945
|
+
|
|
1946
|
+
Returns:
|
|
1947
|
+
the sprite's id
|
|
1948
|
+
"""
|
|
1949
|
+
...
|
|
1950
|
+
|
|
1951
|
+
def collides(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
|
|
1952
|
+
"""
|
|
1953
|
+
Returns true on the first frame that the sprite collides with the
|
|
1954
|
+
target sprite or group.
|
|
1955
|
+
|
|
1956
|
+
Custom collision event handling can be done by using this function
|
|
1957
|
+
in an if statement or adding a callback as the second parameter.
|
|
1958
|
+
"""
|
|
1959
|
+
...
|
|
1960
|
+
|
|
1961
|
+
def colliding(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> float:
|
|
1962
|
+
"""
|
|
1963
|
+
Returns a truthy value while the sprite is colliding with the
|
|
1964
|
+
target sprite or group. The value is the number of frames that
|
|
1965
|
+
the sprite has been colliding with the target.
|
|
1966
|
+
|
|
1967
|
+
Returns:
|
|
1968
|
+
frames
|
|
1969
|
+
"""
|
|
1970
|
+
...
|
|
1971
|
+
|
|
1972
|
+
def collided(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
|
|
1973
|
+
"""
|
|
1974
|
+
Returns true on the first frame that the sprite no longer overlaps
|
|
1975
|
+
with the target sprite or group.
|
|
1976
|
+
"""
|
|
1977
|
+
...
|
|
1978
|
+
|
|
1979
|
+
def overlaps(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
|
|
1980
|
+
"""
|
|
1981
|
+
Returns true on the first frame that the sprite overlaps with the
|
|
1982
|
+
target sprite or group.
|
|
1983
|
+
|
|
1984
|
+
Custom overlap event handling can be done by using this function
|
|
1985
|
+
in an if statement or adding a callback as the second parameter.
|
|
1986
|
+
"""
|
|
1987
|
+
...
|
|
1988
|
+
|
|
1989
|
+
def overlapping(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> float:
|
|
1990
|
+
"""
|
|
1991
|
+
Returns a truthy value while the sprite is overlapping with the
|
|
1992
|
+
target sprite or group. The value returned is the number of
|
|
1993
|
+
frames the sprite has been overlapping with the target.
|
|
1994
|
+
|
|
1995
|
+
Returns:
|
|
1996
|
+
frames
|
|
1997
|
+
"""
|
|
1998
|
+
...
|
|
1999
|
+
|
|
2000
|
+
def overlapped(self, target: Sprite | Group, callback: Callable[..., Any] = ...) -> bool:
|
|
2001
|
+
"""
|
|
2002
|
+
Returns true on the first frame that the sprite no longer overlaps
|
|
2003
|
+
with the target sprite or group.
|
|
2004
|
+
"""
|
|
2005
|
+
...
|
|
2006
|
+
|
|
2007
|
+
def pass_(self, target: Sprite | Group) -> None:
|
|
2008
|
+
"""
|
|
2009
|
+
Sets a pass through contact relationship between the sprite
|
|
2010
|
+
and a target sprite or group.
|
|
2011
|
+
"""
|
|
2012
|
+
...
|
|
2013
|
+
|
|
2014
|
+
def passes(self, target: Sprite | Group) -> None:
|
|
2015
|
+
"""
|
|
2016
|
+
Sets a pass through contact relationship between the sprite
|
|
2017
|
+
and a target sprite or group.
|
|
2018
|
+
"""
|
|
2019
|
+
...
|
|
2020
|
+
|
|
2021
|
+
def addDefaultSensors(self) -> None:
|
|
2022
|
+
"""
|
|
2023
|
+
Creates overlap sensors that are the same size as the sprite's
|
|
2024
|
+
colliders. If you'd like to add more sensors to a sprite, use the
|
|
2025
|
+
`addSensor` function.
|
|
2026
|
+
|
|
2027
|
+
Used internally if a sprite overlap detection
|
|
2028
|
+
function is called but the sprite has no overlap sensors.
|
|
2029
|
+
"""
|
|
2030
|
+
...
|
|
2031
|
+
|
|
2032
|
+
@overload
|
|
2033
|
+
def distanceTo(self, x: float, y: float) -> float:
|
|
2034
|
+
"""
|
|
2035
|
+
Returns the distance to another sprite, the mouse, a touch pointer,
|
|
2036
|
+
or any other object with x and y properties. Uses q5's `dist` function.
|
|
2037
|
+
|
|
2038
|
+
Returns:
|
|
2039
|
+
distance
|
|
2040
|
+
"""
|
|
2041
|
+
...
|
|
2042
|
+
|
|
2043
|
+
@overload
|
|
2044
|
+
def distanceTo(self, pos: dict) -> float:
|
|
2045
|
+
"""
|
|
2046
|
+
Returns the distance to another sprite, the mouse, a touch pointer,
|
|
2047
|
+
or any other object with x and y properties. Uses q5's `dist` function.
|
|
2048
|
+
|
|
2049
|
+
Args:
|
|
2050
|
+
pos: object with x and y properties
|
|
2051
|
+
|
|
2052
|
+
Returns:
|
|
2053
|
+
distance
|
|
2054
|
+
"""
|
|
2055
|
+
...
|
|
2056
|
+
|
|
2057
|
+
def distanceTo(self, pos: dict) -> float:
|
|
2058
|
+
...
|
|
2059
|
+
|
|
2060
|
+
class Ani(list[Image]):
|
|
2061
|
+
|
|
2062
|
+
@classmethod
|
|
2063
|
+
def new(cls, *args: Image) -> 'Ani':
|
|
2064
|
+
"""
|
|
2065
|
+
Ani objects are an array of images
|
|
2066
|
+
that can be displayed by a Visual or Sprite.
|
|
2067
|
+
|
|
2068
|
+
Args:
|
|
2069
|
+
args: the frames of the animation
|
|
2070
|
+
"""
|
|
2071
|
+
...
|
|
2072
|
+
|
|
2073
|
+
def __init__(self, *args: Image) -> None: ...
|
|
2074
|
+
|
|
2075
|
+
name: str
|
|
2076
|
+
"""The name of the animation"""
|
|
2077
|
+
|
|
2078
|
+
targetFrame: float
|
|
2079
|
+
|
|
2080
|
+
offset: dict
|
|
2081
|
+
"""
|
|
2082
|
+
The distance from the sprite or visual's position
|
|
2083
|
+
that the animation is drawn at.
|
|
2084
|
+
"""
|
|
2085
|
+
|
|
2086
|
+
playing: bool
|
|
2087
|
+
"""
|
|
2088
|
+
True if the animation is currently playing.
|
|
2089
|
+
|
|
2090
|
+
Default: `true`
|
|
2091
|
+
"""
|
|
2092
|
+
|
|
2093
|
+
visible: bool
|
|
2094
|
+
"""
|
|
2095
|
+
Animation visibility.
|
|
2096
|
+
|
|
2097
|
+
Default: `true`
|
|
2098
|
+
"""
|
|
2099
|
+
|
|
2100
|
+
looping: bool
|
|
2101
|
+
"""
|
|
2102
|
+
If set to false the animation will stop after reaching the last frame
|
|
2103
|
+
|
|
2104
|
+
Default: `true`
|
|
2105
|
+
"""
|
|
2106
|
+
|
|
2107
|
+
endOnFirstFrame: bool
|
|
2108
|
+
"""
|
|
2109
|
+
Ends the loop on frame 0 instead of the last frame.
|
|
2110
|
+
This is useful for animations that are symmetric.
|
|
2111
|
+
For example a walking cycle where the first frame is the
|
|
2112
|
+
same as the last frame.
|
|
2113
|
+
|
|
2114
|
+
Default: `false`
|
|
2115
|
+
"""
|
|
2116
|
+
|
|
2117
|
+
frameChanged: bool
|
|
2118
|
+
"""True if frame changed during the last draw cycle"""
|
|
2119
|
+
|
|
2120
|
+
onComplete: Any
|
|
2121
|
+
|
|
2122
|
+
onChange: Any
|
|
2123
|
+
|
|
2124
|
+
rotation: Any
|
|
2125
|
+
|
|
2126
|
+
spriteSheet: Any
|
|
2127
|
+
|
|
2128
|
+
@property
|
|
2129
|
+
def frame(self) -> float:
|
|
2130
|
+
"""The index of the current frame that the animation is on."""
|
|
2131
|
+
...
|
|
2132
|
+
|
|
2133
|
+
@frame.setter
|
|
2134
|
+
def frame(self, val: float) -> None: ...
|
|
2135
|
+
|
|
2136
|
+
@property
|
|
2137
|
+
def frameDelay(self) -> float:
|
|
2138
|
+
"""
|
|
2139
|
+
Delay between frames in number of draw cycles.
|
|
2140
|
+
If set to 4 the framerate of the animation would be the
|
|
2141
|
+
sketch framerate divided by 4 (60fps = 15fps)
|
|
2142
|
+
|
|
2143
|
+
Default: `4`
|
|
2144
|
+
"""
|
|
2145
|
+
...
|
|
2146
|
+
|
|
2147
|
+
@frameDelay.setter
|
|
2148
|
+
def frameDelay(self, val: float) -> None: ...
|
|
2149
|
+
|
|
2150
|
+
@property
|
|
2151
|
+
def scale(self) -> float | dict:
|
|
2152
|
+
"""
|
|
2153
|
+
The animation's scale.
|
|
2154
|
+
|
|
2155
|
+
Can be set to a number to scale both x and y
|
|
2156
|
+
or an object with x and/or y properties.
|
|
2157
|
+
|
|
2158
|
+
Default: `1`
|
|
2159
|
+
"""
|
|
2160
|
+
...
|
|
2161
|
+
|
|
2162
|
+
@scale.setter
|
|
2163
|
+
def scale(self, val: float | dict) -> None: ...
|
|
2164
|
+
|
|
2165
|
+
def clone(self) -> Ani:
|
|
2166
|
+
"""
|
|
2167
|
+
Make a copy of the animation, with its own playback state,
|
|
2168
|
+
independent of the original animation.
|
|
2169
|
+
"""
|
|
2170
|
+
...
|
|
2171
|
+
|
|
2172
|
+
def update(self) -> None:
|
|
2173
|
+
"""Updates the animation's playback state. This is called automatically"""
|
|
2174
|
+
...
|
|
2175
|
+
|
|
2176
|
+
def play(self, frame: Any) -> Awaitable[Any]:
|
|
2177
|
+
"""
|
|
2178
|
+
Plays the animation, starting from the specified frame.
|
|
2179
|
+
|
|
2180
|
+
Returns:
|
|
2181
|
+
[Promise] a promise that resolves when the animation completes
|
|
2182
|
+
"""
|
|
2183
|
+
...
|
|
2184
|
+
|
|
2185
|
+
def pause(self, frame: Any) -> None:
|
|
2186
|
+
"""Pauses the animation."""
|
|
2187
|
+
...
|
|
2188
|
+
|
|
2189
|
+
def stop(self, frame: Any) -> None:
|
|
2190
|
+
"""Stops the animation. Alt for pause."""
|
|
2191
|
+
...
|
|
2192
|
+
|
|
2193
|
+
def rewind(self) -> Awaitable[Any]:
|
|
2194
|
+
"""
|
|
2195
|
+
Plays the animation backwards.
|
|
2196
|
+
Equivalent to ani.goToFrame(0)
|
|
2197
|
+
|
|
2198
|
+
Returns:
|
|
2199
|
+
[Promise] a promise that resolves when the animation completes rewinding
|
|
2200
|
+
"""
|
|
2201
|
+
...
|
|
2202
|
+
|
|
2203
|
+
def loop(self) -> None:
|
|
2204
|
+
"""Plays the animation forwards and loops it."""
|
|
2205
|
+
...
|
|
2206
|
+
|
|
2207
|
+
def noLoop(self) -> None:
|
|
2208
|
+
"""Prevents the animation from looping"""
|
|
2209
|
+
...
|
|
2210
|
+
|
|
2211
|
+
def nextFrame(self) -> None:
|
|
2212
|
+
"""Goes to the next frame and stops."""
|
|
2213
|
+
...
|
|
2214
|
+
|
|
2215
|
+
def previousFrame(self) -> None:
|
|
2216
|
+
"""Goes to the previous frame and stops."""
|
|
2217
|
+
...
|
|
2218
|
+
|
|
2219
|
+
def goToFrame(self, toFrame: float) -> Awaitable[Any]:
|
|
2220
|
+
"""
|
|
2221
|
+
Plays the animation forward or backward toward a target frame.
|
|
2222
|
+
|
|
2223
|
+
Args:
|
|
2224
|
+
toFrame: Frame number destination (starts from 0)
|
|
2225
|
+
|
|
2226
|
+
Returns:
|
|
2227
|
+
[Promise] a promise that resolves when the animation completes
|
|
2228
|
+
"""
|
|
2229
|
+
...
|
|
2230
|
+
|
|
2231
|
+
@property
|
|
2232
|
+
def lastFrame(self) -> float:
|
|
2233
|
+
"""The index of the last frame. Read only."""
|
|
2234
|
+
...
|
|
2235
|
+
|
|
2236
|
+
@property
|
|
2237
|
+
def frameImage(self) -> Image:
|
|
2238
|
+
"""The current frame as Q5.Image. Read only."""
|
|
2239
|
+
...
|
|
2240
|
+
|
|
2241
|
+
@property
|
|
2242
|
+
def w(self) -> float:
|
|
2243
|
+
"""Width of the animation's current frame."""
|
|
2244
|
+
...
|
|
2245
|
+
|
|
2246
|
+
@property
|
|
2247
|
+
def width(self) -> float:
|
|
2248
|
+
"""Width of the animation's current frame."""
|
|
2249
|
+
...
|
|
2250
|
+
|
|
2251
|
+
@property
|
|
2252
|
+
def defaultWidth(self) -> Any:
|
|
2253
|
+
...
|
|
2254
|
+
|
|
2255
|
+
@property
|
|
2256
|
+
def h(self) -> float:
|
|
2257
|
+
"""Height of the animation's current frame."""
|
|
2258
|
+
...
|
|
2259
|
+
|
|
2260
|
+
@property
|
|
2261
|
+
def height(self) -> float:
|
|
2262
|
+
"""Height of the animation's current frame."""
|
|
2263
|
+
...
|
|
2264
|
+
|
|
2265
|
+
@property
|
|
2266
|
+
def defaultHeight(self) -> Any:
|
|
2267
|
+
...
|
|
2268
|
+
|
|
2269
|
+
class Anis:
|
|
2270
|
+
"""
|
|
2271
|
+
Stores animations.
|
|
2272
|
+
|
|
2273
|
+
Used internally to create `sprite.anis` and `group.anis`.
|
|
2274
|
+
|
|
2275
|
+
In instances of this class, the keys are animation names,
|
|
2276
|
+
values are Ani objects.
|
|
2277
|
+
"""
|
|
2278
|
+
|
|
2279
|
+
frameDelay: float
|
|
2280
|
+
|
|
2281
|
+
offset: dict
|
|
2282
|
+
|
|
2283
|
+
scale: float | dict
|
|
2284
|
+
|
|
2285
|
+
looping: bool
|
|
2286
|
+
|
|
2287
|
+
playing: bool
|
|
2288
|
+
|
|
2289
|
+
cutFrames: bool
|
|
2290
|
+
"""
|
|
2291
|
+
Cuts sprite sheet frames into separate images, instead of rendering
|
|
2292
|
+
sections of the sprite sheet.
|
|
2293
|
+
|
|
2294
|
+
Avoids edge bleeding artifacts caused by rotation and scaling,
|
|
2295
|
+
but uses more memory and may cause longer load times.
|
|
2296
|
+
"""
|
|
2297
|
+
|
|
2298
|
+
endOnFirstFrame: bool
|
|
2299
|
+
|
|
2300
|
+
w: float
|
|
2301
|
+
|
|
2302
|
+
width: float
|
|
2303
|
+
|
|
2304
|
+
h: float
|
|
2305
|
+
|
|
2306
|
+
height: float
|
|
2307
|
+
|
|
2308
|
+
frameSize: str
|
|
2309
|
+
"""Frame size of the animations in the collection, in the format "WIDTHxHEIGHT", for example "32x32"."""
|
|
2310
|
+
|
|
2311
|
+
spriteSheet: Image
|
|
2312
|
+
"""The sprite sheet image used by the animations in the collection."""
|
|
2313
|
+
|
|
2314
|
+
_T_Visuals = TypeVar('_T_Visuals', bound=Visual)
|
|
2315
|
+
|
|
2316
|
+
class Visuals(list[_T_Visuals], Generic[_T_Visuals]):
|
|
2317
|
+
"""
|
|
2318
|
+
A collection of and blueprint for Visual objects
|
|
2319
|
+
that store an image or animation(s)
|
|
2320
|
+
which can be displayed with respect to the camera.
|
|
2321
|
+
"""
|
|
2322
|
+
|
|
2323
|
+
def draw(self) -> None:
|
|
2324
|
+
"""Draws the visuals on the canvas."""
|
|
2325
|
+
...
|
|
2326
|
+
|
|
2327
|
+
img: Image
|
|
2328
|
+
"""Current image."""
|
|
2329
|
+
|
|
2330
|
+
ani: Ani
|
|
2331
|
+
"""Current animation."""
|
|
2332
|
+
|
|
2333
|
+
@property
|
|
2334
|
+
def anis(self) -> Anis:
|
|
2335
|
+
"""
|
|
2336
|
+
Stores animations.
|
|
2337
|
+
Keys are the animation label, values are Ani objects
|
|
2338
|
+
"""
|
|
2339
|
+
...
|
|
2340
|
+
|
|
2341
|
+
def addAni(self, spriteSheetURL: str, frameCount: float) -> Awaitable[None]:
|
|
2342
|
+
"""
|
|
2343
|
+
Adds an animation to the Group or Visuals array.
|
|
2344
|
+
|
|
2345
|
+
Args:
|
|
2346
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
2347
|
+
frameCount: the number of frames in the sprite sheet
|
|
2348
|
+
|
|
2349
|
+
Returns:
|
|
2350
|
+
A promise that fulfills when the animation is loaded
|
|
2351
|
+
"""
|
|
2352
|
+
...
|
|
2353
|
+
|
|
2354
|
+
@overload
|
|
2355
|
+
def addAnis(self, atlases: dict) -> Awaitable[None]:
|
|
2356
|
+
"""
|
|
2357
|
+
Add multiple animations to the Group or Visuals array.
|
|
2358
|
+
|
|
2359
|
+
Args:
|
|
2360
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
2361
|
+
|
|
2362
|
+
Returns:
|
|
2363
|
+
A promise that fulfills when the animations are loaded
|
|
2364
|
+
"""
|
|
2365
|
+
...
|
|
2366
|
+
|
|
2367
|
+
@overload
|
|
2368
|
+
def addAnis(self, spriteSheetURL: str, atlases: dict) -> Awaitable[None]:
|
|
2369
|
+
"""
|
|
2370
|
+
Add multiple animations to the Group or Visuals array.
|
|
2371
|
+
|
|
2372
|
+
Args:
|
|
2373
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
2374
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
2375
|
+
|
|
2376
|
+
Returns:
|
|
2377
|
+
A promise that fulfills when the animations are loaded
|
|
2378
|
+
"""
|
|
2379
|
+
...
|
|
2380
|
+
|
|
2381
|
+
@overload
|
|
2382
|
+
def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
|
|
2383
|
+
"""
|
|
2384
|
+
Add multiple animations to the Group or Visuals array.
|
|
2385
|
+
|
|
2386
|
+
Args:
|
|
2387
|
+
spriteSheetURL: the URL of the sprite sheet image
|
|
2388
|
+
frameSize: the size of each frame in the sprite sheet in the format "WIDTHxHEIGHT" (example: "32x32")
|
|
2389
|
+
atlases: an object with animation names as keys and an animation or animation atlas as values
|
|
2390
|
+
|
|
2391
|
+
Returns:
|
|
2392
|
+
A promise that fulfills when the animations are loaded
|
|
2393
|
+
"""
|
|
2394
|
+
...
|
|
2395
|
+
|
|
2396
|
+
def addAnis(self, spriteSheetURL: str, frameSize: str, atlases: dict) -> Awaitable[None]:
|
|
2397
|
+
...
|
|
2398
|
+
|
|
2399
|
+
def cull(self, top: float = ..., bottom: float = ..., left: float = ..., right: float = ..., cb: Callable[..., Any] = ...) -> float:
|
|
2400
|
+
"""
|
|
2401
|
+
Detects when visuals go outside the given culling boundary,
|
|
2402
|
+
relative to the camera.
|
|
2403
|
+
|
|
2404
|
+
Args:
|
|
2405
|
+
top: top bound or boundary range
|
|
2406
|
+
bottom: bottom bound
|
|
2407
|
+
left: left bound
|
|
2408
|
+
right: right bound
|
|
2409
|
+
cb: the function to be run when a visual is culled, it's given the visual being culled, if no callback is given then the visual's life is set to 0
|
|
2410
|
+
|
|
2411
|
+
Returns:
|
|
2412
|
+
the number of visuals culled
|
|
2413
|
+
"""
|
|
2414
|
+
...
|
|
2415
|
+
|
|
2416
|
+
tile: str
|
|
2417
|
+
"""The tile character that represents the Visuals or Group in a tile map."""
|
|
2418
|
+
|
|
2419
|
+
def addTiles(self, tiles: list[str], x: float = ..., y: float = ..., colWidth: float = ..., rowHeight: float = ...) -> None:
|
|
2420
|
+
"""
|
|
2421
|
+
Adds sprites to the group based on a tile map.
|
|
2422
|
+
|
|
2423
|
+
Args:
|
|
2424
|
+
x: x coordinate of the top left corner of the tile map, default is -colWidth * longest row / 2
|
|
2425
|
+
y: y coordinate of the top left corner of the tile map, default is -rowHeight * number of rows / 2
|
|
2426
|
+
colWidth: column width including spacing, default is the width of the first tile
|
|
2427
|
+
rowHeight: row height including spacing, default is the height of the first tile
|
|
2428
|
+
"""
|
|
2429
|
+
...
|
|
2430
|
+
|
|
2431
|
+
class Group(Visuals[Sprite]):
|
|
2432
|
+
"""
|
|
2433
|
+
A Group is a collection of and blueprint for
|
|
2434
|
+
sprites with similar traits and behaviors.
|
|
2435
|
+
"""
|
|
2436
|
+
|
|
2437
|
+
@classmethod
|
|
2438
|
+
def new(cls, *sprites: Sprite) -> 'Group':
|
|
2439
|
+
"""
|
|
2440
|
+
A Group is a collection of and blueprint for
|
|
2441
|
+
sprites with similar traits and behaviors.
|
|
2442
|
+
|
|
2443
|
+
Group extends Visuals which extends Array,
|
|
2444
|
+
so you can use them in for loops. They've got
|
|
2445
|
+
all the functions and properties of standard arrays
|
|
2446
|
+
such as `group.length` and functions like `group.includes()`.
|
|
2447
|
+
|
|
2448
|
+
Changing a group setting changes it for all the sprites in the
|
|
2449
|
+
group ("dynamic inheritance").
|
|
2450
|
+
|
|
2451
|
+
All groups inherit from the base group `allSprites`.
|
|
2452
|
+
|
|
2453
|
+
Groups can have subgroups, creating a hierarchy of inheritance.
|
|
2454
|
+
"""
|
|
2455
|
+
...
|
|
2456
|
+
|
|
2457
|
+
def __init__(self, *sprites: Sprite) -> None: ...
|
|
2458
|
+
|
|
2459
|
+
x: float
|
|
2460
|
+
"""Horizontal position of group sprites."""
|
|
2461
|
+
|
|
2462
|
+
y: float
|
|
2463
|
+
"""Vertical position of group sprites."""
|
|
2464
|
+
|
|
2465
|
+
vel: float
|
|
2466
|
+
"""Velocity of group sprites."""
|
|
2467
|
+
|
|
2468
|
+
velocity: float
|
|
2469
|
+
"""Velocity of group sprites."""
|
|
2470
|
+
|
|
2471
|
+
rotation: float
|
|
2472
|
+
"""
|
|
2473
|
+
The angle of the group sprites' rotation, not the direction it's moving.
|
|
2474
|
+
|
|
2475
|
+
If angleMode is set to "degrees", the value will be returned in
|
|
2476
|
+
a range of -180 to 180.
|
|
2477
|
+
"""
|
|
2478
|
+
|
|
2479
|
+
rotationSpeed: float
|
|
2480
|
+
"""The speed of the group sprites' rotation in angles per frame."""
|
|
2481
|
+
|
|
2482
|
+
autoDraw: bool
|
|
2483
|
+
"""If true, group sprites are drawn by q5play after each physics update."""
|
|
2484
|
+
|
|
2485
|
+
allowSleeping: bool
|
|
2486
|
+
"""
|
|
2487
|
+
Controls the ability for group sprites to "sleep".
|
|
2488
|
+
|
|
2489
|
+
"Sleeping" sprites are not included in the physics simulation, a
|
|
2490
|
+
sprite starts "sleeping" when it stops moving and doesn't collide
|
|
2491
|
+
with anything that it wasn't already colliding with.
|
|
2492
|
+
"""
|
|
2493
|
+
|
|
2494
|
+
autoUpdate: float
|
|
2495
|
+
"""If true, group sprites are updated by q5play before each physics update."""
|
|
2496
|
+
|
|
2497
|
+
bearing: float
|
|
2498
|
+
"""
|
|
2499
|
+
A bearing indicates the direction that needs to be followed to
|
|
2500
|
+
reach a destination.
|
|
2501
|
+
|
|
2502
|
+
Setting a group sprites' bearing doesn't do anything by itself.
|
|
2503
|
+
You can apply a force to the group sprites at its bearing angle
|
|
2504
|
+
using the `applyForce` function.
|
|
2505
|
+
"""
|
|
2506
|
+
|
|
2507
|
+
bounciness: float
|
|
2508
|
+
"""The bounciness of the group sprites' physics body."""
|
|
2509
|
+
|
|
2510
|
+
color: Color
|
|
2511
|
+
"""
|
|
2512
|
+
The group sprites' current fill color.
|
|
2513
|
+
|
|
2514
|
+
By default sprites get a random color.
|
|
2515
|
+
"""
|
|
2516
|
+
|
|
2517
|
+
d: float
|
|
2518
|
+
"""The diameter of a circular sprite."""
|
|
2519
|
+
|
|
2520
|
+
diameter: float
|
|
2521
|
+
"""The diameter of a circular sprite."""
|
|
2522
|
+
|
|
2523
|
+
debug: bool
|
|
2524
|
+
"""
|
|
2525
|
+
If true, outlines of the group sprites' colliders and sensors will be drawn.
|
|
2526
|
+
|
|
2527
|
+
Use the keyboard shortcut Command+B to toggle `allSprites.debug`.
|
|
2528
|
+
"""
|
|
2529
|
+
|
|
2530
|
+
density: float
|
|
2531
|
+
"""The density of the group sprites' physics body."""
|
|
2532
|
+
|
|
2533
|
+
direction: float
|
|
2534
|
+
"""The angle of the group sprites' movement."""
|
|
2535
|
+
|
|
2536
|
+
drag: float
|
|
2537
|
+
"""The amount of resistance group sprites has to being moved."""
|
|
2538
|
+
|
|
2539
|
+
friction: float
|
|
2540
|
+
"""
|
|
2541
|
+
The amount the group sprites' colliders resist moving
|
|
2542
|
+
when rubbing against other colliders.
|
|
2543
|
+
"""
|
|
2544
|
+
|
|
2545
|
+
grabbable: bool
|
|
2546
|
+
"""Whether the group sprites can be grabbed by a pointer."""
|
|
2547
|
+
|
|
2548
|
+
gravityScale: float
|
|
2549
|
+
"""A ratio that defines how much the group sprites are affected by gravity."""
|
|
2550
|
+
|
|
2551
|
+
heading: str
|
|
2552
|
+
"""
|
|
2553
|
+
The group sprites' heading. This is a string that can be set to
|
|
2554
|
+
"up", "down", "left", "right", "upRight", "upLeft", "downRight"
|
|
2555
|
+
|
|
2556
|
+
The setter's input parser ignores capitalization, spaces,
|
|
2557
|
+
underscores, dashes, and cardinal direction word order.
|
|
2558
|
+
"""
|
|
2559
|
+
|
|
2560
|
+
h: float
|
|
2561
|
+
"""The height of the group sprites."""
|
|
2562
|
+
|
|
2563
|
+
height: float
|
|
2564
|
+
"""The height of the group sprites."""
|
|
2565
|
+
|
|
2566
|
+
isSuperFast: bool
|
|
2567
|
+
"""
|
|
2568
|
+
Set this to true if the group sprites goes really fast to prevent
|
|
2569
|
+
inaccurate physics simulation.
|
|
2570
|
+
"""
|
|
2571
|
+
|
|
2572
|
+
layer: float
|
|
2573
|
+
"""
|
|
2574
|
+
Sprites with the highest layer value get drawn first.
|
|
2575
|
+
|
|
2576
|
+
By default sprites are drawn in the order they were created in.
|
|
2577
|
+
"""
|
|
2578
|
+
|
|
2579
|
+
life: float
|
|
2580
|
+
"""
|
|
2581
|
+
When the physics simulation is progressed in `world.physicsUpdate`,
|
|
2582
|
+
each sprite's life is decreased by `world.timeScale`.
|
|
2583
|
+
|
|
2584
|
+
If life becomes less than or equal to 0, the group sprites will
|
|
2585
|
+
be removed.
|
|
2586
|
+
"""
|
|
2587
|
+
|
|
2588
|
+
mass: float
|
|
2589
|
+
"""The mass of the group sprites' physics body."""
|
|
2590
|
+
|
|
2591
|
+
physics: str
|
|
2592
|
+
"""
|
|
2593
|
+
The physics type of the group sprites, which determines how it interacts with
|
|
2594
|
+
other sprites in the physics simulation.
|
|
2595
|
+
|
|
2596
|
+
It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
2597
|
+
"""
|
|
2598
|
+
|
|
2599
|
+
physicsType: str
|
|
2600
|
+
"""
|
|
2601
|
+
The physics type of the group sprites, which determines how it interacts with
|
|
2602
|
+
other sprites in the physics simulation.
|
|
2603
|
+
|
|
2604
|
+
It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
2605
|
+
"""
|
|
2606
|
+
|
|
2607
|
+
physicsEnabled: bool
|
|
2608
|
+
"""If true, the group sprites' physics body is included in the physics simulation."""
|
|
2609
|
+
|
|
2610
|
+
pixelPerfect: bool
|
|
2611
|
+
"""
|
|
2612
|
+
If true, q5play will draw sprites at integer pixel precision.
|
|
2613
|
+
|
|
2614
|
+
This is useful for making retro games.
|
|
2615
|
+
|
|
2616
|
+
By default q5play draws sprites with subpixel rendering.
|
|
2617
|
+
"""
|
|
2618
|
+
|
|
2619
|
+
rollingResistance: float
|
|
2620
|
+
"""
|
|
2621
|
+
Simulates friction that slows down group sprites rolling on another sprite,
|
|
2622
|
+
like a soccer ball rolling to a stop on high grass.
|
|
2623
|
+
"""
|
|
2624
|
+
|
|
2625
|
+
rotationDrag: float
|
|
2626
|
+
"""The amount the group sprites resists rotating."""
|
|
2627
|
+
|
|
2628
|
+
rotationLock: bool
|
|
2629
|
+
"""If true, the group sprites can not rotate."""
|
|
2630
|
+
|
|
2631
|
+
scale: float | list | dict
|
|
2632
|
+
"""
|
|
2633
|
+
Horizontal and vertical scale of the group sprites.
|
|
2634
|
+
|
|
2635
|
+
Components can be negative to flip/mirror the group sprites on an axis.
|
|
2636
|
+
|
|
2637
|
+
The `valueOf` function for `sprite.scale` returns the scale as a
|
|
2638
|
+
number. This enables users to do things like `sprite.scale *= 2`
|
|
2639
|
+
to double the group sprites' scale.
|
|
2640
|
+
"""
|
|
2641
|
+
|
|
2642
|
+
sleeping: bool
|
|
2643
|
+
"""
|
|
2644
|
+
Wake group sprites up or put it to sleep.
|
|
2645
|
+
|
|
2646
|
+
"Sleeping" sprites are not included in the physics simulation, a
|
|
2647
|
+
sprite starts "sleeping" when it stops moving and doesn't collide
|
|
2648
|
+
with anything that it wasn't already colliding with.
|
|
2649
|
+
"""
|
|
2650
|
+
|
|
2651
|
+
stroke: Color
|
|
2652
|
+
"""The group sprites' stroke color."""
|
|
2653
|
+
|
|
2654
|
+
strokeWeight: float
|
|
2655
|
+
"""The group sprites' stroke weight, the thickness of its outline."""
|
|
2656
|
+
|
|
2657
|
+
speed: float
|
|
2658
|
+
"""
|
|
2659
|
+
The group sprites' speed.
|
|
2660
|
+
|
|
2661
|
+
Setting speed to a negative value will make the group sprites move
|
|
2662
|
+
180 degrees opposite of its current direction angle.
|
|
2663
|
+
"""
|
|
2664
|
+
|
|
2665
|
+
surfaceSpeed: float
|
|
2666
|
+
"""
|
|
2667
|
+
The group sprites' speed along the surface of its collider(s),
|
|
2668
|
+
like a conveyor belt.
|
|
2669
|
+
"""
|
|
2670
|
+
|
|
2671
|
+
text: float
|
|
2672
|
+
"""Text displayed at the center of the group sprites."""
|
|
2673
|
+
|
|
2674
|
+
textFill: Color
|
|
2675
|
+
"""The group sprites' text fill color. Black by default."""
|
|
2676
|
+
|
|
2677
|
+
textStroke: Color
|
|
2678
|
+
"""
|
|
2679
|
+
The group sprites' text stroke color.
|
|
2680
|
+
No stroke by default, does not inherit from the sketch's stroke color.
|
|
2681
|
+
"""
|
|
2682
|
+
|
|
2683
|
+
textStrokeWeight: float
|
|
2684
|
+
"""
|
|
2685
|
+
The group sprites' text stroke weight, the thickness of its outline.
|
|
2686
|
+
No stroke by default, does not inherit from the sketch's stroke weight.
|
|
2687
|
+
"""
|
|
2688
|
+
|
|
2689
|
+
textSize: float
|
|
2690
|
+
"""The group sprites' text size, the sketch's current textSize by default."""
|
|
2691
|
+
|
|
2692
|
+
visible: bool
|
|
2693
|
+
"""
|
|
2694
|
+
If true the group sprites are shown, if set to false the group sprites are hidden.
|
|
2695
|
+
|
|
2696
|
+
Becomes null when the group sprites are off screen but will be drawn and
|
|
2697
|
+
set to true again if it goes back on screen.
|
|
2698
|
+
"""
|
|
2699
|
+
|
|
2700
|
+
w: float
|
|
2701
|
+
"""The width of the group sprites."""
|
|
2702
|
+
|
|
2703
|
+
width: float
|
|
2704
|
+
"""The width of the group sprites."""
|
|
2705
|
+
|
|
2706
|
+
idNum: float
|
|
2707
|
+
"""
|
|
2708
|
+
Each group has a unique id number. Don't change it!
|
|
2709
|
+
It's useful for debugging.
|
|
2710
|
+
"""
|
|
2711
|
+
|
|
2712
|
+
subgroups: list[dict]
|
|
2713
|
+
"""
|
|
2714
|
+
Groups can have subgroups, which inherit the properties
|
|
2715
|
+
of their parent groups.
|
|
2716
|
+
|
|
2717
|
+
Default: `[]`
|
|
2718
|
+
"""
|
|
2719
|
+
|
|
2720
|
+
parent: Any
|
|
2721
|
+
"""The direct parent group that this group inherits properties from."""
|
|
2722
|
+
|
|
2723
|
+
Sprite: Type[Sprite]
|
|
2724
|
+
"""Creates a new sprite with the traits of the group and adds it to the group."""
|
|
2725
|
+
|
|
2726
|
+
Group: Type[Group]
|
|
2727
|
+
"""Creates a new subgroup that inherits the traits of the group."""
|
|
2728
|
+
|
|
2729
|
+
autoCull: bool
|
|
2730
|
+
"""
|
|
2731
|
+
A property of the `allSprites` group only,
|
|
2732
|
+
that controls whether sprites are automatically deleted
|
|
2733
|
+
when they are 10,000 pixels away from the camera.
|
|
2734
|
+
|
|
2735
|
+
It only needs to be set to false once and then it will
|
|
2736
|
+
remain false for the rest of the sketch, unless changed.
|
|
2737
|
+
"""
|
|
2738
|
+
|
|
2739
|
+
visualOnly: bool
|
|
2740
|
+
"""New group sprites will not have physics bodies (can't have colliders)."""
|
|
2741
|
+
|
|
2742
|
+
add: Callable[..., float]
|
|
2743
|
+
"""
|
|
2744
|
+
Alias for `group.push`.
|
|
2745
|
+
|
|
2746
|
+
Adds a sprite to the end of the group.
|
|
2747
|
+
"""
|
|
2748
|
+
|
|
2749
|
+
contains: Callable[..., bool]
|
|
2750
|
+
"""
|
|
2751
|
+
Alias for `group.includes`.
|
|
2752
|
+
|
|
2753
|
+
Check if a sprite is in the group.
|
|
2754
|
+
"""
|
|
2755
|
+
|
|
2756
|
+
@property
|
|
2757
|
+
def amount(self) -> float:
|
|
2758
|
+
"""
|
|
2759
|
+
Depending on the value that the amount property is set to, the group will
|
|
2760
|
+
either add or delete sprites.
|
|
2761
|
+
"""
|
|
2762
|
+
...
|
|
2763
|
+
|
|
2764
|
+
@amount.setter
|
|
2765
|
+
def amount(self, val: float) -> None: ...
|
|
2766
|
+
|
|
2767
|
+
def collides(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
|
|
2768
|
+
"""
|
|
2769
|
+
Returns true on the first frame that the group collides with the
|
|
2770
|
+
target group.
|
|
2771
|
+
|
|
2772
|
+
Custom collision event handling can be done by using this function
|
|
2773
|
+
in an if statement or adding a callback as the second parameter.
|
|
2774
|
+
"""
|
|
2775
|
+
...
|
|
2776
|
+
|
|
2777
|
+
def colliding(self, target: Group, callback: Callable[..., Any] = ...) -> float:
|
|
2778
|
+
"""
|
|
2779
|
+
Returns the amount of frames that the group has been colliding
|
|
2780
|
+
with the target group for, which is a truthy value. Returns 0 if
|
|
2781
|
+
the group is not colliding with the target group.
|
|
2782
|
+
|
|
2783
|
+
Returns:
|
|
2784
|
+
frames
|
|
2785
|
+
"""
|
|
2786
|
+
...
|
|
2787
|
+
|
|
2788
|
+
def collided(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
|
|
2789
|
+
"""
|
|
2790
|
+
Returns true on the first frame that the group no longer overlaps
|
|
2791
|
+
with the target group.
|
|
2792
|
+
"""
|
|
2793
|
+
...
|
|
2794
|
+
|
|
2795
|
+
def overlaps(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
|
|
2796
|
+
"""
|
|
2797
|
+
Returns true on the first frame that the group overlaps with the
|
|
2798
|
+
target group.
|
|
2799
|
+
|
|
2800
|
+
Custom overlap event handling can be done by using this function
|
|
2801
|
+
in an if statement or adding a callback as the second parameter.
|
|
2802
|
+
"""
|
|
2803
|
+
...
|
|
2804
|
+
|
|
2805
|
+
def overlapping(self, target: Group, callback: Callable[..., Any] = ...) -> float:
|
|
2806
|
+
"""
|
|
2807
|
+
Returns the amount of frames that the group has been overlapping
|
|
2808
|
+
with the target group for, which is a truthy value. Returns 0 if
|
|
2809
|
+
the group is not overlapping with the target group.
|
|
2810
|
+
|
|
2811
|
+
Returns:
|
|
2812
|
+
frames
|
|
2813
|
+
"""
|
|
2814
|
+
...
|
|
2815
|
+
|
|
2816
|
+
def overlapped(self, target: Group, callback: Callable[..., Any] = ...) -> bool:
|
|
2817
|
+
"""
|
|
2818
|
+
Returns true on the first frame that the group no longer overlaps
|
|
2819
|
+
with the target group.
|
|
2820
|
+
"""
|
|
2821
|
+
...
|
|
2822
|
+
|
|
2823
|
+
def pass_(self, target: Group) -> None:
|
|
2824
|
+
"""Sets a pass through contact relationship between the group and the target group."""
|
|
2825
|
+
...
|
|
2826
|
+
|
|
2827
|
+
def passes(self, target: Group) -> None:
|
|
2828
|
+
"""Sets a pass through contact relationship between the group and the target group."""
|
|
2829
|
+
...
|
|
2830
|
+
|
|
2831
|
+
@overload
|
|
2832
|
+
def applyForce(self, amount: float, origin: dict = ...) -> None:
|
|
2833
|
+
"""Applies a force magnitude to the group at its bearing."""
|
|
2834
|
+
...
|
|
2835
|
+
|
|
2836
|
+
@overload
|
|
2837
|
+
def applyForce(self, force: dict, origin: dict = ...) -> None:
|
|
2838
|
+
"""Applies a force vector to the group."""
|
|
2839
|
+
...
|
|
2840
|
+
|
|
2841
|
+
def applyForce(self, force: dict, origin: dict = ...) -> None:
|
|
2842
|
+
...
|
|
2843
|
+
|
|
2844
|
+
@overload
|
|
2845
|
+
def applyForceScaled(self, amount: float, origin: dict = ...) -> None:
|
|
2846
|
+
"""Applies a force scaled to member masses using a magnitude."""
|
|
2847
|
+
...
|
|
2848
|
+
|
|
2849
|
+
@overload
|
|
2850
|
+
def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
|
|
2851
|
+
"""Applies a force scaled to member masses using a vector."""
|
|
2852
|
+
...
|
|
2853
|
+
|
|
2854
|
+
def applyForceScaled(self, force: dict, origin: dict = ...) -> None:
|
|
2855
|
+
...
|
|
2856
|
+
|
|
2857
|
+
def applyWind(self, speed: float, angle: float, drag: float = ..., lift: float = ...) -> None:
|
|
2858
|
+
...
|
|
2859
|
+
|
|
2860
|
+
@overload
|
|
2861
|
+
def attractTo(self, x: float, y: float, force: float = ...) -> None:
|
|
2862
|
+
"""
|
|
2863
|
+
Applies a force to the group's center of mass attracting it to
|
|
2864
|
+
the given position.
|
|
2865
|
+
"""
|
|
2866
|
+
...
|
|
2867
|
+
|
|
2868
|
+
@overload
|
|
2869
|
+
def attractTo(self, pos: dict, force: float = ...) -> None:
|
|
2870
|
+
"""
|
|
2871
|
+
Applies a force to the group's center of mass attracting it to
|
|
2872
|
+
the given position.
|
|
2873
|
+
"""
|
|
2874
|
+
...
|
|
2875
|
+
|
|
2876
|
+
def attractTo(self, pos: dict, force: float = ...) -> None:
|
|
2877
|
+
...
|
|
2878
|
+
|
|
2879
|
+
def applyTorque(self, torque: Any) -> None:
|
|
2880
|
+
...
|
|
2881
|
+
|
|
2882
|
+
@overload
|
|
2883
|
+
def moveTo(self, x: float | None, y: float | None, speed: float = ...) -> Awaitable[bool]:
|
|
2884
|
+
"""
|
|
2885
|
+
Moves each sprite in the group to a destination at a constant speed,
|
|
2886
|
+
maintaining their relative offsets from the group's centroid.
|
|
2887
|
+
"""
|
|
2888
|
+
...
|
|
2889
|
+
|
|
2890
|
+
@overload
|
|
2891
|
+
def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
|
|
2892
|
+
"""
|
|
2893
|
+
Moves each sprite in the group to a destination at a constant speed,
|
|
2894
|
+
maintaining their relative offsets from the group's centroid.
|
|
2895
|
+
"""
|
|
2896
|
+
...
|
|
2897
|
+
|
|
2898
|
+
def moveTo(self, pos: dict, speed: float = ...) -> Awaitable[bool]:
|
|
2899
|
+
...
|
|
2900
|
+
|
|
2901
|
+
@overload
|
|
2902
|
+
def moveTowards(self, x: float | None, y: float | None, tracking: float = ...) -> None:
|
|
2903
|
+
"""Moves the group towards a position."""
|
|
2904
|
+
...
|
|
2905
|
+
|
|
2906
|
+
@overload
|
|
2907
|
+
def moveTowards(self, pos: dict, tracking: float = ...) -> None:
|
|
2908
|
+
"""Moves the group towards a position."""
|
|
2909
|
+
...
|
|
2910
|
+
|
|
2911
|
+
def moveTowards(self, pos: dict, tracking: float = ...) -> None:
|
|
2912
|
+
...
|
|
2913
|
+
|
|
2914
|
+
@overload
|
|
2915
|
+
def rotateTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
|
|
2916
|
+
"""
|
|
2917
|
+
Rotates each sprite in the group to a target angle. The sign of `speed`
|
|
2918
|
+
determines direction: positive = CW, negative = CCW.
|
|
2919
|
+
"""
|
|
2920
|
+
...
|
|
2921
|
+
|
|
2922
|
+
@overload
|
|
2923
|
+
def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
2924
|
+
"""
|
|
2925
|
+
Rotates each sprite in the group to face a position. The sign of `speed`
|
|
2926
|
+
determines direction: positive = CW, negative = CCW.
|
|
2927
|
+
"""
|
|
2928
|
+
...
|
|
2929
|
+
|
|
2930
|
+
def rotateTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
2931
|
+
...
|
|
2932
|
+
|
|
2933
|
+
def rotate(self, angle: float, speed: float = ...) -> Awaitable[bool]:
|
|
2934
|
+
"""Rotates each sprite in the group by the given angle amount at the given speed."""
|
|
2935
|
+
...
|
|
2936
|
+
|
|
2937
|
+
@overload
|
|
2938
|
+
def rotateMinTo(self, angle: float, speed: float = ...) -> Awaitable[bool]:
|
|
2939
|
+
"""
|
|
2940
|
+
Rotates each sprite in the group by the smallest angular distance to
|
|
2941
|
+
a target angle, stopping when they arrive.
|
|
2942
|
+
"""
|
|
2943
|
+
...
|
|
2944
|
+
|
|
2945
|
+
@overload
|
|
2946
|
+
def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
2947
|
+
"""
|
|
2948
|
+
Rotates each sprite in the group by the smallest angular distance to
|
|
2949
|
+
face a position, stopping when they arrive.
|
|
2950
|
+
"""
|
|
2951
|
+
...
|
|
2952
|
+
|
|
2953
|
+
def rotateMinTo(self, pos: dict, speed: float = ..., facing: float = ...) -> Awaitable[bool]:
|
|
2954
|
+
...
|
|
2955
|
+
|
|
2956
|
+
@overload
|
|
2957
|
+
def rotateTowards(self, angle: float, tracking: float = ...) -> None:
|
|
2958
|
+
"""Rotates each sprite in the group towards an angle."""
|
|
2959
|
+
...
|
|
2960
|
+
|
|
2961
|
+
@overload
|
|
2962
|
+
def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
|
|
2963
|
+
"""Rotates each sprite in the group towards a position."""
|
|
2964
|
+
...
|
|
2965
|
+
|
|
2966
|
+
def rotateTowards(self, pos: dict, tracking: float = ..., facing: float = ...) -> None:
|
|
2967
|
+
...
|
|
2968
|
+
|
|
2969
|
+
@overload
|
|
2970
|
+
def transformTowards(self, x: float, y: float, rotation: float = ..., tracking: float = ...) -> None:
|
|
2971
|
+
"""
|
|
2972
|
+
Moves and rotates each sprite in the group towards a target transform,
|
|
2973
|
+
maintaining their relative offsets from the group's centroid.
|
|
2974
|
+
"""
|
|
2975
|
+
...
|
|
2976
|
+
|
|
2977
|
+
@overload
|
|
2978
|
+
def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
|
|
2979
|
+
"""
|
|
2980
|
+
Moves and rotates each sprite in the group towards a target transform,
|
|
2981
|
+
maintaining their relative offsets from the group's centroid.
|
|
2982
|
+
"""
|
|
2983
|
+
...
|
|
2984
|
+
|
|
2985
|
+
def transformTowards(self, pos: dict, rotation: float = ..., tracking: float = ...) -> None:
|
|
2986
|
+
...
|
|
2987
|
+
|
|
2988
|
+
@overload
|
|
2989
|
+
def repelFrom(self, x: float, y: float, force: float = ...) -> None:
|
|
2990
|
+
"""Applies a repelling force from a position."""
|
|
2991
|
+
...
|
|
2992
|
+
|
|
2993
|
+
@overload
|
|
2994
|
+
def repelFrom(self, pos: dict, force: float = ...) -> None:
|
|
2995
|
+
"""Applies a repelling force from a position."""
|
|
2996
|
+
...
|
|
2997
|
+
|
|
2998
|
+
def repelFrom(self, pos: dict, force: float = ...) -> None:
|
|
2999
|
+
...
|
|
3000
|
+
|
|
3001
|
+
def cull(self, top: float = ..., bottom: float = ..., left: float = ..., right: float = ..., cb: Callable[..., Any] = ...) -> float:
|
|
3002
|
+
"""
|
|
3003
|
+
Detects when sprites go outside the given culling boundary
|
|
3004
|
+
relative to the camera.
|
|
3005
|
+
|
|
3006
|
+
By default, culled sprites are deleted, but a callback function
|
|
3007
|
+
can be provided to perform other operations on the culled sprites.
|
|
3008
|
+
|
|
3009
|
+
Args:
|
|
3010
|
+
top: the distance that sprites can move below the canvas before they are removed
|
|
3011
|
+
bottom: the distance that sprites can move below the canvas before they are removed
|
|
3012
|
+
left: the distance that sprites can move beyond the left side of the canvas before they are removed
|
|
3013
|
+
right: the distance that sprites can move beyond the right side of the canvas before they are removed
|
|
3014
|
+
cb: the function to be run when a sprite is culled, it's given the sprite being culled, if no callback is given then the sprite is removed
|
|
3015
|
+
|
|
3016
|
+
Returns:
|
|
3017
|
+
the number of sprites culled
|
|
3018
|
+
"""
|
|
3019
|
+
...
|
|
3020
|
+
|
|
3021
|
+
def splice(self, start: float, removalCount: float, *sprites: Sprite) -> list[Sprite]:
|
|
3022
|
+
"""
|
|
3023
|
+
If removalCount is greater than 0, that amount of
|
|
3024
|
+
sprites starting from the start index will be removed
|
|
3025
|
+
from this group and its sub groups recursively (if any),
|
|
3026
|
+
|
|
3027
|
+
Then any provided sprites will be added at the start index
|
|
3028
|
+
to this group and at the end of each of its parent groups recursively,
|
|
3029
|
+
if not already present in parent groups.
|
|
3030
|
+
|
|
3031
|
+
Args:
|
|
3032
|
+
start: start index
|
|
3033
|
+
removalCount: number of sprites to remove, starting from the start index
|
|
3034
|
+
sprites: sprites to add at start index
|
|
3035
|
+
|
|
3036
|
+
Returns:
|
|
3037
|
+
the removed sprites
|
|
3038
|
+
"""
|
|
3039
|
+
...
|
|
3040
|
+
|
|
3041
|
+
def remove(self, item: Sprite | float) -> Sprite: # type: ignore[override]
|
|
3042
|
+
"""
|
|
3043
|
+
Removes a sprite from this group and its sub groups (if any),
|
|
3044
|
+
but does not delete it from the world.
|
|
3045
|
+
|
|
3046
|
+
Args:
|
|
3047
|
+
item: the sprite to be deleted or its index
|
|
3048
|
+
|
|
3049
|
+
Returns:
|
|
3050
|
+
the deleted sprite or undefined if the specified sprite was not found
|
|
3051
|
+
"""
|
|
3052
|
+
...
|
|
3053
|
+
|
|
3054
|
+
def removeAll(self) -> list[Sprite]:
|
|
3055
|
+
"""
|
|
3056
|
+
Removes all sprites from this group without deleting them.
|
|
3057
|
+
|
|
3058
|
+
Returns:
|
|
3059
|
+
the removed sprites
|
|
3060
|
+
"""
|
|
3061
|
+
...
|
|
3062
|
+
|
|
3063
|
+
def delete(self) -> None:
|
|
3064
|
+
"""
|
|
3065
|
+
Deletes the group and all its sprites
|
|
3066
|
+
from the world and every other group they belong to.
|
|
3067
|
+
|
|
3068
|
+
Don't attempt to use a group after deleting it.
|
|
3069
|
+
"""
|
|
3070
|
+
...
|
|
3071
|
+
|
|
3072
|
+
def deleteAll(self) -> None:
|
|
3073
|
+
"""
|
|
3074
|
+
Deletes all the sprites in the group.
|
|
3075
|
+
|
|
3076
|
+
Does not delete the group itself.
|
|
3077
|
+
"""
|
|
3078
|
+
...
|
|
3079
|
+
|
|
3080
|
+
def update(self) -> None:
|
|
3081
|
+
"""Updates all the sprites in the group."""
|
|
3082
|
+
...
|
|
3083
|
+
|
|
3084
|
+
def draw(self) -> None:
|
|
3085
|
+
"""Draws all the sprites in the group."""
|
|
3086
|
+
...
|
|
3087
|
+
|
|
3088
|
+
class World:
|
|
3089
|
+
"""The World is the Box2D physics simulation."""
|
|
3090
|
+
|
|
3091
|
+
@property
|
|
3092
|
+
def gravity(self) -> Any:
|
|
3093
|
+
"""
|
|
3094
|
+
Gravity force vector that affects all dynamic physics colliders.
|
|
3095
|
+
|
|
3096
|
+
Default: `{ x: 0, y: 0 }`
|
|
3097
|
+
"""
|
|
3098
|
+
...
|
|
3099
|
+
|
|
3100
|
+
@gravity.setter
|
|
3101
|
+
def gravity(self, val: Any) -> None: ...
|
|
3102
|
+
|
|
3103
|
+
@property
|
|
3104
|
+
def bounceThreshold(self) -> float:
|
|
3105
|
+
"""
|
|
3106
|
+
The lowest velocity an object can have before it is considered
|
|
3107
|
+
to be at rest.
|
|
3108
|
+
|
|
3109
|
+
Adjust the bounce threshold to allow for slow moving objects
|
|
3110
|
+
but don't have it be too low, or else objects will never sleep,
|
|
3111
|
+
which will hurt performance.
|
|
3112
|
+
|
|
3113
|
+
Default: `0.19`
|
|
3114
|
+
"""
|
|
3115
|
+
...
|
|
3116
|
+
|
|
3117
|
+
@bounceThreshold.setter
|
|
3118
|
+
def bounceThreshold(self, val: float) -> None: ...
|
|
3119
|
+
|
|
3120
|
+
physicsTime: float
|
|
3121
|
+
"""The time elapsed in the physics simulation in seconds."""
|
|
3122
|
+
|
|
3123
|
+
meterSize: float
|
|
3124
|
+
"""
|
|
3125
|
+
Represents the size of a meter in pixels.
|
|
3126
|
+
|
|
3127
|
+
Adjusting this property changes the simulated scale of the physics world.
|
|
3128
|
+
For optimal results, it should be set such that sprites are between
|
|
3129
|
+
0.1 and 10 meters in size in the physics simulation.
|
|
3130
|
+
|
|
3131
|
+
The default value is 60, which means that your sprites should optimally
|
|
3132
|
+
be between 6 and 600 pixels in size.
|
|
3133
|
+
|
|
3134
|
+
Default: `60`
|
|
3135
|
+
"""
|
|
3136
|
+
|
|
3137
|
+
autoStep: bool
|
|
3138
|
+
"""
|
|
3139
|
+
|
|
3140
|
+
Default: `true`
|
|
3141
|
+
"""
|
|
3142
|
+
|
|
3143
|
+
def physicsUpdate(self, timeStep: float = ...) -> None:
|
|
3144
|
+
"""
|
|
3145
|
+
Performs a physics simulation step that advances all sprites
|
|
3146
|
+
forward in time by 1 / updateRate * timeScale if no timeStep is given.
|
|
3147
|
+
"""
|
|
3148
|
+
...
|
|
3149
|
+
|
|
3150
|
+
@property
|
|
3151
|
+
def timeScale(self) -> float:
|
|
3152
|
+
"""
|
|
3153
|
+
A time scale of 1.0 represents real time.
|
|
3154
|
+
Accepts decimal values between 0 and 2.
|
|
3155
|
+
|
|
3156
|
+
Default: `1.0`
|
|
3157
|
+
"""
|
|
3158
|
+
...
|
|
3159
|
+
|
|
3160
|
+
@timeScale.setter
|
|
3161
|
+
def timeScale(self, val: float) -> None: ...
|
|
3162
|
+
|
|
3163
|
+
@property
|
|
3164
|
+
def updateRate(self) -> float:
|
|
3165
|
+
"""
|
|
3166
|
+
The fixed update rate of the physics simulation in hertz.
|
|
3167
|
+
|
|
3168
|
+
The time step, the amount of time that passes during a
|
|
3169
|
+
physics update, is calculated to be: 1 / updateRate * timeScale
|
|
3170
|
+
|
|
3171
|
+
Setting the update rate to a value lower than 50hz is not
|
|
3172
|
+
recommended, as simulation quality will degrade.
|
|
3173
|
+
|
|
3174
|
+
Default: `60`
|
|
3175
|
+
"""
|
|
3176
|
+
...
|
|
3177
|
+
|
|
3178
|
+
@updateRate.setter
|
|
3179
|
+
def updateRate(self, val: float) -> None: ...
|
|
3180
|
+
|
|
3181
|
+
@property
|
|
3182
|
+
def realTime(self) -> float:
|
|
3183
|
+
"""
|
|
3184
|
+
The real time in seconds since the world was created, including
|
|
3185
|
+
time spent paused.
|
|
3186
|
+
"""
|
|
3187
|
+
...
|
|
3188
|
+
|
|
3189
|
+
@overload
|
|
3190
|
+
def getSpritesAt(self, x: float, y: float, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
|
|
3191
|
+
"""
|
|
3192
|
+
Returns the sprites at a position, ordered by layer.
|
|
3193
|
+
|
|
3194
|
+
Sprites must have a physics body to be detected.
|
|
3195
|
+
|
|
3196
|
+
Args:
|
|
3197
|
+
x: x coordinate or object with x and y properties
|
|
3198
|
+
radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
3199
|
+
group: limit results to a specific group, allSprites by default
|
|
3200
|
+
cameraActiveWhenDrawn: limit results to sprites drawn when the camera was active, true by default
|
|
3201
|
+
|
|
3202
|
+
Returns:
|
|
3203
|
+
an array of sprites
|
|
3204
|
+
"""
|
|
3205
|
+
...
|
|
3206
|
+
|
|
3207
|
+
@overload
|
|
3208
|
+
def getSpritesAt(self, pos: dict, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
|
|
3209
|
+
"""
|
|
3210
|
+
Returns the sprites at a position, ordered by layer.
|
|
3211
|
+
|
|
3212
|
+
Sprites must have a physics body to be detected.
|
|
3213
|
+
|
|
3214
|
+
Args:
|
|
3215
|
+
pos: object with x and y properties
|
|
3216
|
+
radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
3217
|
+
group: limit results to a specific group, allSprites by default
|
|
3218
|
+
cameraActiveWhenDrawn: limit results to sprites drawn when the camera was active, true by default
|
|
3219
|
+
|
|
3220
|
+
Returns:
|
|
3221
|
+
an array of sprites
|
|
3222
|
+
"""
|
|
3223
|
+
...
|
|
3224
|
+
|
|
3225
|
+
def getSpritesAt(self, pos: dict, radius: float = ..., group: Group = ..., cameraActiveWhenDrawn: bool = ...) -> list[Sprite]:
|
|
3226
|
+
...
|
|
3227
|
+
|
|
3228
|
+
@overload
|
|
3229
|
+
def getSpriteAt(self, x: float, y: float, radius: float = ..., group: Group = ...) -> Sprite:
|
|
3230
|
+
"""
|
|
3231
|
+
Returns the sprite at the specified position
|
|
3232
|
+
on the top most layer, drawn when the camera was on.
|
|
3233
|
+
|
|
3234
|
+
The sprite must have a physics body to be detected.
|
|
3235
|
+
|
|
3236
|
+
Args:
|
|
3237
|
+
x: x coordinate or object with x and y properties
|
|
3238
|
+
radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
3239
|
+
group: the group to search
|
|
3240
|
+
|
|
3241
|
+
Returns:
|
|
3242
|
+
a sprite
|
|
3243
|
+
"""
|
|
3244
|
+
...
|
|
3245
|
+
|
|
3246
|
+
@overload
|
|
3247
|
+
def getSpriteAt(self, pos: dict, radius: float = ..., group: Group = ...) -> Sprite:
|
|
3248
|
+
"""
|
|
3249
|
+
Returns the sprite at the specified position
|
|
3250
|
+
on the top most layer, drawn when the camera was on.
|
|
3251
|
+
|
|
3252
|
+
The sprite must have a physics body to be detected.
|
|
3253
|
+
|
|
3254
|
+
Args:
|
|
3255
|
+
pos: object with x and y properties
|
|
3256
|
+
radius: the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
3257
|
+
group: the group to search
|
|
3258
|
+
|
|
3259
|
+
Returns:
|
|
3260
|
+
a sprite
|
|
3261
|
+
"""
|
|
3262
|
+
...
|
|
3263
|
+
|
|
3264
|
+
def getSpriteAt(self, pos: dict, radius: float = ..., group: Group = ...) -> Sprite:
|
|
3265
|
+
...
|
|
3266
|
+
|
|
3267
|
+
@property
|
|
3268
|
+
def allowSleeping(self) -> bool:
|
|
3269
|
+
"""
|
|
3270
|
+
"Sleeping" sprites get temporarily ignored during physics
|
|
3271
|
+
simulation. A sprite starts "sleeping" when it stops moving and
|
|
3272
|
+
doesn't collide with anything that it wasn't already touching.
|
|
3273
|
+
|
|
3274
|
+
This is an important performance optimization that you probably
|
|
3275
|
+
shouldn't disable for every sprite in the world.
|
|
3276
|
+
|
|
3277
|
+
Default: `true`
|
|
3278
|
+
"""
|
|
3279
|
+
...
|
|
3280
|
+
|
|
3281
|
+
@allowSleeping.setter
|
|
3282
|
+
def allowSleeping(self, val: bool) -> None: ...
|
|
3283
|
+
|
|
3284
|
+
@overload
|
|
3285
|
+
def rayCast(self, startPos: list[dict | float], direction: float, maxDistance: float = ...) -> Sprite:
|
|
3286
|
+
"""
|
|
3287
|
+
Finds the first sprite (with a physics body) that
|
|
3288
|
+
intersects a ray (line).
|
|
3289
|
+
|
|
3290
|
+
Args:
|
|
3291
|
+
startPos: starting position of the ray cast, object with x and y properties or array [x, y]
|
|
3292
|
+
direction: direction angle of the ray
|
|
3293
|
+
maxDistance: max distance the ray should check, default 10000
|
|
3294
|
+
|
|
3295
|
+
Returns:
|
|
3296
|
+
The first sprite the ray hits or undefined
|
|
3297
|
+
"""
|
|
3298
|
+
...
|
|
3299
|
+
|
|
3300
|
+
@overload
|
|
3301
|
+
def rayCast(self, startPos: list[dict | float], endPos: list[dict | float]) -> Sprite:
|
|
3302
|
+
"""
|
|
3303
|
+
Finds the first sprite (with a physics body) that
|
|
3304
|
+
intersects a ray from startPos to endPos.
|
|
3305
|
+
|
|
3306
|
+
Args:
|
|
3307
|
+
startPos: starting position of the ray cast
|
|
3308
|
+
endPos: end position of the ray cast
|
|
3309
|
+
|
|
3310
|
+
Returns:
|
|
3311
|
+
The first sprite the ray hits or undefined
|
|
3312
|
+
"""
|
|
3313
|
+
...
|
|
3314
|
+
|
|
3315
|
+
def rayCast(self, startPos: list[dict | float], endPos: list[dict | float]) -> Sprite:
|
|
3316
|
+
...
|
|
3317
|
+
|
|
3318
|
+
@overload
|
|
3319
|
+
def rayCastAll(self, startPos: list[dict | float], direction: float, maxDistance: float = ..., limiter: Callable[..., Any] = ...) -> list[Sprite]:
|
|
3320
|
+
"""
|
|
3321
|
+
Finds all sprites (with physics bodies) that intersect
|
|
3322
|
+
a ray (line), sorted by distance.
|
|
3323
|
+
|
|
3324
|
+
Args:
|
|
3325
|
+
startPos: starting position of the ray cast, object with x and y properties or array [x, y]
|
|
3326
|
+
direction: direction angle of the ray
|
|
3327
|
+
maxDistance: max distance the ray should check, default 10000
|
|
3328
|
+
limiter: callback run each time the ray hits a sprite; return true to stop the ray
|
|
3329
|
+
|
|
3330
|
+
Returns:
|
|
3331
|
+
An array of sprites that the ray cast hit, sorted by distance. The sprite closest to the starting point will be at index 0. If a limiter is provided, this array includes the sprite that caused the ray to stop.
|
|
3332
|
+
"""
|
|
3333
|
+
...
|
|
3334
|
+
|
|
3335
|
+
@overload
|
|
3336
|
+
def rayCastAll(self, startPos: list[dict | float], endPos: list[dict | float], limiter: Callable[..., Any] = ...) -> list[Sprite]:
|
|
3337
|
+
"""
|
|
3338
|
+
Finds all sprites (with physics bodies) that intersect
|
|
3339
|
+
a ray from startPos to endPos, sorted by distance.
|
|
3340
|
+
|
|
3341
|
+
Args:
|
|
3342
|
+
startPos: starting position of the ray cast
|
|
3343
|
+
endPos: end position of the ray cast
|
|
3344
|
+
limiter: callback run each time the ray hits a sprite; return true to stop the ray
|
|
3345
|
+
|
|
3346
|
+
Returns:
|
|
3347
|
+
An array of sprites that the ray cast hit, sorted by distance.
|
|
3348
|
+
"""
|
|
3349
|
+
...
|
|
3350
|
+
|
|
3351
|
+
def rayCastAll(self, startPos: list[dict | float], endPos: list[dict | float], limiter: Callable[..., Any] = ...) -> list[Sprite]:
|
|
3352
|
+
...
|
|
3353
|
+
|
|
3354
|
+
def circleCast(self, startPos: list[dict | float], endPos: list[dict | float], radius: float) -> Sprite:
|
|
3355
|
+
"""
|
|
3356
|
+
Finds the first sprite (with a physics body) that
|
|
3357
|
+
intersects a swept circle (capsule cast) from startPos to endPos.
|
|
3358
|
+
|
|
3359
|
+
Args:
|
|
3360
|
+
startPos: starting position of the cast, object with x and y properties or array [x, y]
|
|
3361
|
+
endPos: end position of the cast
|
|
3362
|
+
radius: radius of the circle
|
|
3363
|
+
|
|
3364
|
+
Returns:
|
|
3365
|
+
The first sprite hit or undefined
|
|
3366
|
+
"""
|
|
3367
|
+
...
|
|
3368
|
+
|
|
3369
|
+
def circleCastAll(self, startPos: list[dict | float], endPos: list[dict | float], radius: float, limiter: Callable[..., Any] = ...) -> list[Sprite]:
|
|
3370
|
+
"""
|
|
3371
|
+
Finds all sprites (with physics bodies) that intersect
|
|
3372
|
+
a swept circle (capsule cast) from startPos to endPos, sorted by distance.
|
|
3373
|
+
|
|
3374
|
+
Args:
|
|
3375
|
+
startPos: starting position of the cast
|
|
3376
|
+
endPos: end position of the cast
|
|
3377
|
+
radius: radius of the circle
|
|
3378
|
+
limiter: callback run each time the cast hits a sprite; return true to stop the cast
|
|
3379
|
+
|
|
3380
|
+
Returns:
|
|
3381
|
+
An array of sprites hit, sorted by distance.
|
|
3382
|
+
"""
|
|
3383
|
+
...
|
|
3384
|
+
|
|
3385
|
+
@overload
|
|
3386
|
+
def explodeAt(self, x: float, y: float, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
|
|
3387
|
+
"""
|
|
3388
|
+
Applies an explosive force to sprites within the radius of the explosion.
|
|
3389
|
+
|
|
3390
|
+
Args:
|
|
3391
|
+
x: x coordinate or object with x and y properties of the center of the explosion
|
|
3392
|
+
radius: the distance from the center of the explosion that sprites can be affected by the explosion
|
|
3393
|
+
magnitude: the strength of the explosion force, default is 1
|
|
3394
|
+
falloff: how much the explosion force decreases as sprites are farther from the center of the explosion, default is 0.1 (10% decrease per pixel)
|
|
3395
|
+
"""
|
|
3396
|
+
...
|
|
3397
|
+
|
|
3398
|
+
@overload
|
|
3399
|
+
def explodeAt(self, pos: dict, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
|
|
3400
|
+
...
|
|
3401
|
+
|
|
3402
|
+
def explodeAt(self, pos: dict, radius: float = ..., magnitude: float = ..., falloff: float = ...) -> None:
|
|
3403
|
+
...
|
|
3404
|
+
|
|
3405
|
+
@property
|
|
3406
|
+
def awakeBodies(self) -> float:
|
|
3407
|
+
"""The number of physics bodies currently awake in the world."""
|
|
3408
|
+
...
|
|
3409
|
+
|
|
3410
|
+
@property
|
|
3411
|
+
def hitThreshold(self) -> float:
|
|
3412
|
+
"""The minimum impact velocity needed for a hit event to be fired."""
|
|
3413
|
+
...
|
|
3414
|
+
|
|
3415
|
+
@hitThreshold.setter
|
|
3416
|
+
def hitThreshold(self, val: float) -> None: ...
|
|
3417
|
+
|
|
3418
|
+
@property
|
|
3419
|
+
def profile(self) -> Any:
|
|
3420
|
+
"""Box2D world performance profile data."""
|
|
3421
|
+
...
|
|
3422
|
+
|
|
3423
|
+
@property
|
|
3424
|
+
def debugInfo(self) -> Any:
|
|
3425
|
+
"""Box2D world counter/statistics data."""
|
|
3426
|
+
...
|
|
3427
|
+
|
|
3428
|
+
subSteps: float
|
|
3429
|
+
"""
|
|
3430
|
+
The number of sub-steps per physics update.
|
|
3431
|
+
More sub-steps increases accuracy at the cost of performance.
|
|
3432
|
+
|
|
3433
|
+
Default: `4`
|
|
3434
|
+
"""
|
|
3435
|
+
|
|
3436
|
+
def step(self, timeStep: float = ...) -> None:
|
|
3437
|
+
"""Alias for `physicsUpdate`."""
|
|
3438
|
+
...
|
|
3439
|
+
|
|
3440
|
+
wID: Any
|
|
3441
|
+
"""The Box2D world ID. Don't change it!"""
|
|
3442
|
+
|
|
3443
|
+
class Camera:
|
|
3444
|
+
"""The Camera controls the position and zoom of the view of the world that is drawn on the canvas."""
|
|
3445
|
+
|
|
3446
|
+
isActive: bool
|
|
3447
|
+
"""
|
|
3448
|
+
Read only. True if the camera is active.
|
|
3449
|
+
Use camera.on() to activate the camera.
|
|
3450
|
+
|
|
3451
|
+
Default: `false`
|
|
3452
|
+
"""
|
|
3453
|
+
|
|
3454
|
+
@property
|
|
3455
|
+
def x(self) -> float:
|
|
3456
|
+
"""The camera's x position."""
|
|
3457
|
+
...
|
|
3458
|
+
|
|
3459
|
+
@x.setter
|
|
3460
|
+
def x(self, val: float) -> None: ...
|
|
3461
|
+
|
|
3462
|
+
@property
|
|
3463
|
+
def y(self) -> float:
|
|
3464
|
+
"""The camera's y position."""
|
|
3465
|
+
...
|
|
3466
|
+
|
|
3467
|
+
@y.setter
|
|
3468
|
+
def y(self, val: float) -> None: ...
|
|
3469
|
+
|
|
3470
|
+
@property
|
|
3471
|
+
def pos(self) -> dict:
|
|
3472
|
+
"""
|
|
3473
|
+
Gets the camera's position as a readonly {x, y} object that
|
|
3474
|
+
won't be updated if the camera moves. Useful for saving the
|
|
3475
|
+
camera's position at a specific moment in time.
|
|
3476
|
+
"""
|
|
3477
|
+
...
|
|
3478
|
+
|
|
3479
|
+
@pos.setter
|
|
3480
|
+
def pos(self, val: list[float] | dict) -> None: ...
|
|
3481
|
+
|
|
3482
|
+
@property
|
|
3483
|
+
def position(self) -> Vector:
|
|
3484
|
+
"""The camera's position vector."""
|
|
3485
|
+
...
|
|
3486
|
+
|
|
3487
|
+
@position.setter
|
|
3488
|
+
def position(self, val: list[float] | dict) -> None: ...
|
|
3489
|
+
|
|
3490
|
+
def moveTo(self, x: float, y: float, speed: float) -> Awaitable[bool]:
|
|
3491
|
+
"""
|
|
3492
|
+
Moves the camera to a position.
|
|
3493
|
+
|
|
3494
|
+
Returns:
|
|
3495
|
+
resolves true when the camera reaches the target position
|
|
3496
|
+
"""
|
|
3497
|
+
...
|
|
3498
|
+
|
|
3499
|
+
@property
|
|
3500
|
+
def zoom(self) -> float:
|
|
3501
|
+
"""
|
|
3502
|
+
Camera zoom.
|
|
3503
|
+
|
|
3504
|
+
A scale of 1 will be the normal size. Setting it to 2
|
|
3505
|
+
will make everything appear twice as big. .5 will make
|
|
3506
|
+
everything look half size.
|
|
3507
|
+
|
|
3508
|
+
Default: `1`
|
|
3509
|
+
"""
|
|
3510
|
+
...
|
|
3511
|
+
|
|
3512
|
+
@zoom.setter
|
|
3513
|
+
def zoom(self, val: float) -> None: ...
|
|
3514
|
+
|
|
3515
|
+
def zoomTo(self, target: float, speed: float) -> Awaitable[bool]:
|
|
3516
|
+
"""
|
|
3517
|
+
Zoom the camera at a given speed.
|
|
3518
|
+
|
|
3519
|
+
Args:
|
|
3520
|
+
target: The target zoom
|
|
3521
|
+
speed: The amount of zoom per frame
|
|
3522
|
+
|
|
3523
|
+
Returns:
|
|
3524
|
+
resolves true when the camera reaches the target zoom
|
|
3525
|
+
"""
|
|
3526
|
+
...
|
|
3527
|
+
|
|
3528
|
+
def on(self) -> None:
|
|
3529
|
+
"""
|
|
3530
|
+
Activates the camera.
|
|
3531
|
+
|
|
3532
|
+
The canvas will be drawn according to the camera position and scale until
|
|
3533
|
+
camera.off() is called.
|
|
3534
|
+
"""
|
|
3535
|
+
...
|
|
3536
|
+
|
|
3537
|
+
def off(self) -> None:
|
|
3538
|
+
"""
|
|
3539
|
+
Deactivates the camera.
|
|
3540
|
+
|
|
3541
|
+
The canvas will be drawn normally, ignoring the camera's position
|
|
3542
|
+
and scale until camera.on() is called.
|
|
3543
|
+
"""
|
|
3544
|
+
...
|
|
3545
|
+
|
|
3546
|
+
class Joint:
|
|
3547
|
+
"""
|
|
3548
|
+
A Joint is used to constrain the movement of two sprites relative
|
|
3549
|
+
to each other, which can lead to nuanced physics interactions.
|
|
3550
|
+
"""
|
|
3551
|
+
|
|
3552
|
+
@classmethod
|
|
3553
|
+
def new(cls, spriteA: Sprite, spriteB: Sprite, type_: str = ...) -> 'Joint':
|
|
3554
|
+
"""
|
|
3555
|
+
Don't use the Joint constructor directly, use one of these
|
|
3556
|
+
joint constructors instead:
|
|
3557
|
+
|
|
3558
|
+
GlueJoint, DistanceJoint, WheelJoint, HingeJoint,
|
|
3559
|
+
SliderJoint, or GrabberJoint.
|
|
3560
|
+
"""
|
|
3561
|
+
...
|
|
3562
|
+
|
|
3563
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite, type_: str = ...) -> None: ...
|
|
3564
|
+
|
|
3565
|
+
spriteA: Sprite
|
|
3566
|
+
"""The first sprite in the joint."""
|
|
3567
|
+
|
|
3568
|
+
spriteB: Sprite
|
|
3569
|
+
"""The second sprite in the joint."""
|
|
3570
|
+
|
|
3571
|
+
type: str
|
|
3572
|
+
"""
|
|
3573
|
+
The type of joint. Can be one of:
|
|
3574
|
+
|
|
3575
|
+
"glue", "distance", "wheel", "hinge", "slider", or "grabber".
|
|
3576
|
+
|
|
3577
|
+
Can't be changed after the joint is created.
|
|
3578
|
+
"""
|
|
3579
|
+
|
|
3580
|
+
visible: bool
|
|
3581
|
+
"""
|
|
3582
|
+
Determines whether to draw the joint if spriteA
|
|
3583
|
+
or spriteB is drawn.
|
|
3584
|
+
|
|
3585
|
+
Default: `true`
|
|
3586
|
+
"""
|
|
3587
|
+
|
|
3588
|
+
@property
|
|
3589
|
+
def offsetA(self) -> Vector:
|
|
3590
|
+
"""
|
|
3591
|
+
Offset to the joint's anchorA position from the center of spriteA.
|
|
3592
|
+
|
|
3593
|
+
Only distance and hinge joints have an offsetA.
|
|
3594
|
+
|
|
3595
|
+
Default: `{x: 0, y: 0}`
|
|
3596
|
+
"""
|
|
3597
|
+
...
|
|
3598
|
+
|
|
3599
|
+
@offsetA.setter
|
|
3600
|
+
def offsetA(self, val: list | dict | Vector) -> None: ...
|
|
3601
|
+
|
|
3602
|
+
@property
|
|
3603
|
+
def offsetB(self) -> Vector:
|
|
3604
|
+
"""
|
|
3605
|
+
Offset to the joint's anchorB position from the center of spriteB.
|
|
3606
|
+
|
|
3607
|
+
Only distance, hinge, and wheel joints have an offsetB.
|
|
3608
|
+
|
|
3609
|
+
Default: `{x: 0, y: 0}`
|
|
3610
|
+
"""
|
|
3611
|
+
...
|
|
3612
|
+
|
|
3613
|
+
@offsetB.setter
|
|
3614
|
+
def offsetB(self, val: list | dict | Vector) -> None: ...
|
|
3615
|
+
|
|
3616
|
+
@property
|
|
3617
|
+
def draw(self) -> Callable[..., Any]:
|
|
3618
|
+
"""Function that draws the joint. Can be overridden by the user."""
|
|
3619
|
+
...
|
|
3620
|
+
|
|
3621
|
+
@draw.setter
|
|
3622
|
+
def draw(self, val: Callable[..., Any]) -> None: ...
|
|
3623
|
+
|
|
3624
|
+
@property
|
|
3625
|
+
def collideConnected(self) -> bool:
|
|
3626
|
+
"""
|
|
3627
|
+
Set to true if you want the joint's sprites to collide with
|
|
3628
|
+
each other.
|
|
3629
|
+
|
|
3630
|
+
Default: `false`
|
|
3631
|
+
"""
|
|
3632
|
+
...
|
|
3633
|
+
|
|
3634
|
+
@collideConnected.setter
|
|
3635
|
+
def collideConnected(self, val: bool) -> None: ...
|
|
3636
|
+
|
|
3637
|
+
@property
|
|
3638
|
+
def reactionForce(self) -> Any:
|
|
3639
|
+
"""How much force the joint is applying to keep the two sprites together."""
|
|
3640
|
+
...
|
|
3641
|
+
|
|
3642
|
+
@property
|
|
3643
|
+
def reactionTorque(self) -> Any:
|
|
3644
|
+
"""How much torque the joint is applying to keep the two sprites together."""
|
|
3645
|
+
...
|
|
3646
|
+
|
|
3647
|
+
@property
|
|
3648
|
+
def forceThreshold(self) -> float:
|
|
3649
|
+
"""
|
|
3650
|
+
The amount of force that must be applied to the joint before it breaks.
|
|
3651
|
+
|
|
3652
|
+
Setting the threshold too high leads to instability. Use
|
|
3653
|
+
`sprite.addCollider` to simulate unbreakable bonds between shapes.
|
|
3654
|
+
|
|
3655
|
+
Default: `500`
|
|
3656
|
+
"""
|
|
3657
|
+
...
|
|
3658
|
+
|
|
3659
|
+
@forceThreshold.setter
|
|
3660
|
+
def forceThreshold(self, val: float) -> None: ...
|
|
3661
|
+
|
|
3662
|
+
@property
|
|
3663
|
+
def torqueThreshold(self) -> float:
|
|
3664
|
+
"""
|
|
3665
|
+
The amount of torque that must be applied to the joint before it breaks.
|
|
3666
|
+
|
|
3667
|
+
Setting the threshold too high leads to instability. Use
|
|
3668
|
+
`sprite.addCollider` to simulate unbreakable bonds between shapes.
|
|
3669
|
+
|
|
3670
|
+
Default: `500`
|
|
3671
|
+
"""
|
|
3672
|
+
...
|
|
3673
|
+
|
|
3674
|
+
@torqueThreshold.setter
|
|
3675
|
+
def torqueThreshold(self, val: float) -> None: ...
|
|
3676
|
+
|
|
3677
|
+
def onStrain(self) -> None:
|
|
3678
|
+
"""
|
|
3679
|
+
This function is run when the joint's reaction force exceeds the
|
|
3680
|
+
force threshold or its reaction torque exceeds the torque threshold.
|
|
3681
|
+
|
|
3682
|
+
By default, the sprites' speed and rotation speed are set to 0
|
|
3683
|
+
and the joint is deleted, simulating a break.
|
|
3684
|
+
"""
|
|
3685
|
+
...
|
|
3686
|
+
|
|
3687
|
+
def delete(self) -> None:
|
|
3688
|
+
"""
|
|
3689
|
+
Deletes the joint from the world and from each of the
|
|
3690
|
+
associated sprites' joints arrays.
|
|
3691
|
+
"""
|
|
3692
|
+
...
|
|
3693
|
+
|
|
3694
|
+
jID: Any
|
|
3695
|
+
"""The Box2D joint ID. Don't change it!"""
|
|
3696
|
+
|
|
3697
|
+
class GlueJoint(Joint):
|
|
3698
|
+
|
|
3699
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
|
|
3700
|
+
|
|
3701
|
+
@property
|
|
3702
|
+
def springiness(self) -> float:
|
|
3703
|
+
...
|
|
3704
|
+
|
|
3705
|
+
@springiness.setter
|
|
3706
|
+
def springiness(self, val: float) -> None: ...
|
|
3707
|
+
|
|
3708
|
+
@property
|
|
3709
|
+
def damping(self) -> float:
|
|
3710
|
+
...
|
|
3711
|
+
|
|
3712
|
+
@damping.setter
|
|
3713
|
+
def damping(self, val: float) -> None: ...
|
|
3714
|
+
|
|
3715
|
+
class DistanceJoint(Joint):
|
|
3716
|
+
|
|
3717
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
|
|
3718
|
+
|
|
3719
|
+
@property
|
|
3720
|
+
def currentLength(self) -> float:
|
|
3721
|
+
"""The current distance between the two joint anchors."""
|
|
3722
|
+
...
|
|
3723
|
+
|
|
3724
|
+
@property
|
|
3725
|
+
def length(self) -> float:
|
|
3726
|
+
"""
|
|
3727
|
+
The target length of the joint between the two joint anchors.
|
|
3728
|
+
|
|
3729
|
+
It's set to the current distance between the two sprites
|
|
3730
|
+
when the joint is created.
|
|
3731
|
+
"""
|
|
3732
|
+
...
|
|
3733
|
+
|
|
3734
|
+
@length.setter
|
|
3735
|
+
def length(self, val: float) -> None: ...
|
|
3736
|
+
|
|
3737
|
+
@property
|
|
3738
|
+
def limitsEnabled(self) -> bool:
|
|
3739
|
+
"""
|
|
3740
|
+
Whether the joint's length limits are enabled.
|
|
3741
|
+
When enabled a min/max length range constrains the joint.
|
|
3742
|
+
|
|
3743
|
+
Default: `false`
|
|
3744
|
+
"""
|
|
3745
|
+
...
|
|
3746
|
+
|
|
3747
|
+
@limitsEnabled.setter
|
|
3748
|
+
def limitsEnabled(self, val: bool) -> None: ...
|
|
3749
|
+
|
|
3750
|
+
@property
|
|
3751
|
+
def minLength(self) -> float:
|
|
3752
|
+
"""The minimum length allowed when limits are enabled."""
|
|
3753
|
+
...
|
|
3754
|
+
|
|
3755
|
+
@property
|
|
3756
|
+
def maxLength(self) -> float:
|
|
3757
|
+
"""The maximum length allowed when limits are enabled."""
|
|
3758
|
+
...
|
|
3759
|
+
|
|
3760
|
+
@property
|
|
3761
|
+
def range(self) -> Any:
|
|
3762
|
+
"""
|
|
3763
|
+
Accepts a number to set a symmetric range
|
|
3764
|
+
or an array with the minimum and maximum length limits.
|
|
3765
|
+
"""
|
|
3766
|
+
...
|
|
3767
|
+
|
|
3768
|
+
@range.setter
|
|
3769
|
+
def range(self, val: tuple[float, float] | float) -> None: ...
|
|
3770
|
+
|
|
3771
|
+
@property
|
|
3772
|
+
def springEnabled(self) -> bool:
|
|
3773
|
+
"""
|
|
3774
|
+
Whether spring behavior is enabled for the joint.
|
|
3775
|
+
|
|
3776
|
+
Default: `true`
|
|
3777
|
+
"""
|
|
3778
|
+
...
|
|
3779
|
+
|
|
3780
|
+
@springEnabled.setter
|
|
3781
|
+
def springEnabled(self, val: bool) -> None: ...
|
|
3782
|
+
|
|
3783
|
+
@property
|
|
3784
|
+
def springiness(self) -> float:
|
|
3785
|
+
"""
|
|
3786
|
+
The springiness of the joint, a 0-1 ratio.
|
|
3787
|
+
|
|
3788
|
+
0 is rigid, 0.5 is bouncy, 1 is loose.
|
|
3789
|
+
|
|
3790
|
+
Default: `0`
|
|
3791
|
+
"""
|
|
3792
|
+
...
|
|
3793
|
+
|
|
3794
|
+
@springiness.setter
|
|
3795
|
+
def springiness(self, val: float) -> None: ...
|
|
3796
|
+
|
|
3797
|
+
@property
|
|
3798
|
+
def damping(self) -> float:
|
|
3799
|
+
"""
|
|
3800
|
+
Damping is a 0-1 ratio describing how quickly the joint loses
|
|
3801
|
+
vibrational energy.
|
|
3802
|
+
|
|
3803
|
+
0.0 means no damping, 1.0 means critical damping, which will stop
|
|
3804
|
+
the joint from vibrating at all.
|
|
3805
|
+
|
|
3806
|
+
Damping only effects joints that have a
|
|
3807
|
+
springiness greater than 0.
|
|
3808
|
+
|
|
3809
|
+
Default: `0.0`
|
|
3810
|
+
"""
|
|
3811
|
+
...
|
|
3812
|
+
|
|
3813
|
+
@damping.setter
|
|
3814
|
+
def damping(self, val: float) -> None: ...
|
|
3815
|
+
|
|
3816
|
+
@property
|
|
3817
|
+
def motorEnabled(self) -> bool:
|
|
3818
|
+
"""
|
|
3819
|
+
Whether the joint's motor is enabled.
|
|
3820
|
+
|
|
3821
|
+
Default: `false`
|
|
3822
|
+
"""
|
|
3823
|
+
...
|
|
3824
|
+
|
|
3825
|
+
@motorEnabled.setter
|
|
3826
|
+
def motorEnabled(self, val: bool) -> None: ...
|
|
3827
|
+
|
|
3828
|
+
@property
|
|
3829
|
+
def speed(self) -> float:
|
|
3830
|
+
"""
|
|
3831
|
+
Motor speed.
|
|
3832
|
+
|
|
3833
|
+
Default: `0`
|
|
3834
|
+
"""
|
|
3835
|
+
...
|
|
3836
|
+
|
|
3837
|
+
@speed.setter
|
|
3838
|
+
def speed(self, val: float) -> None: ...
|
|
3839
|
+
|
|
3840
|
+
@property
|
|
3841
|
+
def maxPower(self) -> float:
|
|
3842
|
+
"""Maximum motor force the motor can apply."""
|
|
3843
|
+
...
|
|
3844
|
+
|
|
3845
|
+
@maxPower.setter
|
|
3846
|
+
def maxPower(self, val: float) -> None: ...
|
|
3847
|
+
|
|
3848
|
+
@property
|
|
3849
|
+
def power(self) -> float:
|
|
3850
|
+
"""The current motor force being applied by the joint."""
|
|
3851
|
+
...
|
|
3852
|
+
|
|
3853
|
+
class WheelJoint(Joint):
|
|
3854
|
+
|
|
3855
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
|
|
3856
|
+
|
|
3857
|
+
@property
|
|
3858
|
+
def angle(self) -> float:
|
|
3859
|
+
"""
|
|
3860
|
+
The angle at which the wheel is attached to the vehicle body.
|
|
3861
|
+
|
|
3862
|
+
The default is 90 degrees (PI/2 in radians).
|
|
3863
|
+
|
|
3864
|
+
Default: `90`
|
|
3865
|
+
"""
|
|
3866
|
+
...
|
|
3867
|
+
|
|
3868
|
+
@angle.setter
|
|
3869
|
+
def angle(self, val: float) -> None: ...
|
|
3870
|
+
|
|
3871
|
+
@property
|
|
3872
|
+
def limitsEnabled(self) -> bool:
|
|
3873
|
+
"""
|
|
3874
|
+
Whether the joint's suspension limits are enabled.
|
|
3875
|
+
When enabled a min/max distance from resting constrains the joint.
|
|
3876
|
+
|
|
3877
|
+
Default: `false`
|
|
3878
|
+
"""
|
|
3879
|
+
...
|
|
3880
|
+
|
|
3881
|
+
@limitsEnabled.setter
|
|
3882
|
+
def limitsEnabled(self, val: bool) -> None: ...
|
|
3883
|
+
|
|
3884
|
+
@property
|
|
3885
|
+
def lowerLimit(self) -> float:
|
|
3886
|
+
"""
|
|
3887
|
+
The minimum distance the wheel's suspension can contract
|
|
3888
|
+
from 0, which represents the resting position,
|
|
3889
|
+
when limits are enabled.
|
|
3890
|
+
"""
|
|
3891
|
+
...
|
|
3892
|
+
|
|
3893
|
+
@property
|
|
3894
|
+
def upperLimit(self) -> float:
|
|
3895
|
+
"""
|
|
3896
|
+
The maximum distance the wheel's suspension can extend
|
|
3897
|
+
from 0, which represents the resting position,
|
|
3898
|
+
when limits are enabled.
|
|
3899
|
+
"""
|
|
3900
|
+
...
|
|
3901
|
+
|
|
3902
|
+
@property
|
|
3903
|
+
def range(self) -> Any:
|
|
3904
|
+
"""
|
|
3905
|
+
The distance the wheel's suspension can contract or extend
|
|
3906
|
+
from 0, which represents the resting position.
|
|
3907
|
+
|
|
3908
|
+
Accepts a number to set a symmetric range
|
|
3909
|
+
or an array with the minimum and maximum length limits.
|
|
3910
|
+
"""
|
|
3911
|
+
...
|
|
3912
|
+
|
|
3913
|
+
@range.setter
|
|
3914
|
+
def range(self, val: tuple[float, float] | float) -> None: ...
|
|
3915
|
+
|
|
3916
|
+
@property
|
|
3917
|
+
def springEnabled(self) -> bool:
|
|
3918
|
+
"""
|
|
3919
|
+
Whether the wheel joint has suspension,
|
|
3920
|
+
which can make it ride smoother over bumps.
|
|
3921
|
+
|
|
3922
|
+
Default: `true`
|
|
3923
|
+
"""
|
|
3924
|
+
...
|
|
3925
|
+
|
|
3926
|
+
@springEnabled.setter
|
|
3927
|
+
def springEnabled(self, val: bool) -> None: ...
|
|
3928
|
+
|
|
3929
|
+
@property
|
|
3930
|
+
def springiness(self) -> float:
|
|
3931
|
+
"""
|
|
3932
|
+
The springiness of the joint, a 0-1 ratio.
|
|
3933
|
+
|
|
3934
|
+
0.0 is rigid, 0.5 is bouncy, 1.0 is loose.
|
|
3935
|
+
|
|
3936
|
+
Default: `0.0`
|
|
3937
|
+
"""
|
|
3938
|
+
...
|
|
3939
|
+
|
|
3940
|
+
@springiness.setter
|
|
3941
|
+
def springiness(self, val: float) -> None: ...
|
|
3942
|
+
|
|
3943
|
+
@property
|
|
3944
|
+
def damping(self) -> float:
|
|
3945
|
+
"""
|
|
3946
|
+
Damping is a 0-1 ratio describing how quickly the joint loses
|
|
3947
|
+
vibrational energy.
|
|
3948
|
+
|
|
3949
|
+
0.0 means no damping, 1.0 means critical damping, which will stop
|
|
3950
|
+
the joint from vibrating at all.
|
|
3951
|
+
|
|
3952
|
+
Damping only effects joints that have a
|
|
3953
|
+
springiness greater than 0.
|
|
3954
|
+
|
|
3955
|
+
Default: `0.0`
|
|
3956
|
+
"""
|
|
3957
|
+
...
|
|
3958
|
+
|
|
3959
|
+
@damping.setter
|
|
3960
|
+
def damping(self, val: float) -> None: ...
|
|
3961
|
+
|
|
3962
|
+
@property
|
|
3963
|
+
def motorEnabled(self) -> bool:
|
|
3964
|
+
"""
|
|
3965
|
+
Whether the joint's motor is enabled.
|
|
3966
|
+
|
|
3967
|
+
Default: `false`
|
|
3968
|
+
"""
|
|
3969
|
+
...
|
|
3970
|
+
|
|
3971
|
+
@motorEnabled.setter
|
|
3972
|
+
def motorEnabled(self, val: bool) -> None: ...
|
|
3973
|
+
|
|
3974
|
+
@property
|
|
3975
|
+
def speed(self) -> float:
|
|
3976
|
+
"""
|
|
3977
|
+
Motor speed.
|
|
3978
|
+
|
|
3979
|
+
Default: `0`
|
|
3980
|
+
"""
|
|
3981
|
+
...
|
|
3982
|
+
|
|
3983
|
+
@speed.setter
|
|
3984
|
+
def speed(self, val: float) -> None: ...
|
|
3985
|
+
|
|
3986
|
+
@property
|
|
3987
|
+
def maxPower(self) -> float:
|
|
3988
|
+
"""Maximum torque the motor can apply."""
|
|
3989
|
+
...
|
|
3990
|
+
|
|
3991
|
+
@maxPower.setter
|
|
3992
|
+
def maxPower(self, val: float) -> None: ...
|
|
3993
|
+
|
|
3994
|
+
@property
|
|
3995
|
+
def power(self) -> float:
|
|
3996
|
+
"""The current torque being applied by the motor."""
|
|
3997
|
+
...
|
|
3998
|
+
|
|
3999
|
+
class HingeJoint(Joint):
|
|
4000
|
+
|
|
4001
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
|
|
4002
|
+
|
|
4003
|
+
@property
|
|
4004
|
+
def limitsEnabled(self) -> bool:
|
|
4005
|
+
"""
|
|
4006
|
+
Whether the joint's angle limits are enabled.
|
|
4007
|
+
When enabled a min/max angle range constrains the joint.
|
|
4008
|
+
|
|
4009
|
+
Default: `false`
|
|
4010
|
+
"""
|
|
4011
|
+
...
|
|
4012
|
+
|
|
4013
|
+
@limitsEnabled.setter
|
|
4014
|
+
def limitsEnabled(self, val: bool) -> None: ...
|
|
4015
|
+
|
|
4016
|
+
@property
|
|
4017
|
+
def minAngle(self) -> float:
|
|
4018
|
+
"""The lower limit of rotation."""
|
|
4019
|
+
...
|
|
4020
|
+
|
|
4021
|
+
@property
|
|
4022
|
+
def maxAngle(self) -> float:
|
|
4023
|
+
"""The upper limit of rotation."""
|
|
4024
|
+
...
|
|
4025
|
+
|
|
4026
|
+
@property
|
|
4027
|
+
def range(self) -> Any:
|
|
4028
|
+
"""
|
|
4029
|
+
Accepts a number to set a symmetric range
|
|
4030
|
+
or an array with the lower and upper limits of rotation.
|
|
4031
|
+
"""
|
|
4032
|
+
...
|
|
4033
|
+
|
|
4034
|
+
@range.setter
|
|
4035
|
+
def range(self, val: tuple[float, float] | float) -> None: ...
|
|
4036
|
+
|
|
4037
|
+
@property
|
|
4038
|
+
def angle(self) -> float:
|
|
4039
|
+
"""The joint's current angle of rotation."""
|
|
4040
|
+
...
|
|
4041
|
+
|
|
4042
|
+
@property
|
|
4043
|
+
def springEnabled(self) -> bool:
|
|
4044
|
+
"""
|
|
4045
|
+
Whether spring behavior is enabled.
|
|
4046
|
+
|
|
4047
|
+
Default: `false`
|
|
4048
|
+
"""
|
|
4049
|
+
...
|
|
4050
|
+
|
|
4051
|
+
@springEnabled.setter
|
|
4052
|
+
def springEnabled(self, val: bool) -> None: ...
|
|
4053
|
+
|
|
4054
|
+
@property
|
|
4055
|
+
def springiness(self) -> float:
|
|
4056
|
+
"""
|
|
4057
|
+
The springiness of the joint, a 0-1 ratio.
|
|
4058
|
+
|
|
4059
|
+
0 is rigid, 0.5 is bouncy, 1 is loose.
|
|
4060
|
+
|
|
4061
|
+
Default: `0`
|
|
4062
|
+
"""
|
|
4063
|
+
...
|
|
4064
|
+
|
|
4065
|
+
@springiness.setter
|
|
4066
|
+
def springiness(self, val: float) -> None: ...
|
|
4067
|
+
|
|
4068
|
+
@property
|
|
4069
|
+
def damping(self) -> float:
|
|
4070
|
+
"""
|
|
4071
|
+
Damping ratio, 0-1. Higher values reduce oscillation faster.
|
|
4072
|
+
|
|
4073
|
+
Default: `0`
|
|
4074
|
+
"""
|
|
4075
|
+
...
|
|
4076
|
+
|
|
4077
|
+
@damping.setter
|
|
4078
|
+
def damping(self, val: float) -> None: ...
|
|
4079
|
+
|
|
4080
|
+
@property
|
|
4081
|
+
def motorEnabled(self) -> bool:
|
|
4082
|
+
"""
|
|
4083
|
+
Whether the joint's motor is enabled.
|
|
4084
|
+
|
|
4085
|
+
Default: `false`
|
|
4086
|
+
"""
|
|
4087
|
+
...
|
|
4088
|
+
|
|
4089
|
+
@motorEnabled.setter
|
|
4090
|
+
def motorEnabled(self, val: bool) -> None: ...
|
|
4091
|
+
|
|
4092
|
+
@property
|
|
4093
|
+
def speed(self) -> float:
|
|
4094
|
+
"""
|
|
4095
|
+
Motor speed.
|
|
4096
|
+
|
|
4097
|
+
Default: `0`
|
|
4098
|
+
"""
|
|
4099
|
+
...
|
|
4100
|
+
|
|
4101
|
+
@speed.setter
|
|
4102
|
+
def speed(self, val: float) -> None: ...
|
|
4103
|
+
|
|
4104
|
+
@property
|
|
4105
|
+
def maxPower(self) -> float:
|
|
4106
|
+
"""Maximum torque the motor can apply."""
|
|
4107
|
+
...
|
|
4108
|
+
|
|
4109
|
+
@maxPower.setter
|
|
4110
|
+
def maxPower(self, val: float) -> None: ...
|
|
4111
|
+
|
|
4112
|
+
@property
|
|
4113
|
+
def power(self) -> float:
|
|
4114
|
+
"""The current torque being applied by the motor."""
|
|
4115
|
+
...
|
|
4116
|
+
|
|
4117
|
+
class SliderJoint(Joint):
|
|
4118
|
+
|
|
4119
|
+
def __init__(self, spriteA: Sprite, spriteB: Sprite) -> None: ...
|
|
4120
|
+
|
|
4121
|
+
@property
|
|
4122
|
+
def translation(self) -> float:
|
|
4123
|
+
"""The current displacement of spriteB along the slide axis."""
|
|
4124
|
+
...
|
|
4125
|
+
|
|
4126
|
+
@property
|
|
4127
|
+
def limitsEnabled(self) -> bool:
|
|
4128
|
+
"""
|
|
4129
|
+
Whether the joint's translation limits are enabled.
|
|
4130
|
+
|
|
4131
|
+
Default: `false`
|
|
4132
|
+
"""
|
|
4133
|
+
...
|
|
4134
|
+
|
|
4135
|
+
@limitsEnabled.setter
|
|
4136
|
+
def limitsEnabled(self, val: bool) -> None: ...
|
|
4137
|
+
|
|
4138
|
+
@property
|
|
4139
|
+
def lowerLimit(self) -> float:
|
|
4140
|
+
"""The mathematical lower limit of translation."""
|
|
4141
|
+
...
|
|
4142
|
+
|
|
4143
|
+
@property
|
|
4144
|
+
def upperLimit(self) -> float:
|
|
4145
|
+
"""The mathematical upper limit of translation."""
|
|
4146
|
+
...
|
|
4147
|
+
|
|
4148
|
+
@property
|
|
4149
|
+
def range(self) -> Any:
|
|
4150
|
+
"""
|
|
4151
|
+
Accepts a number to set a symmetric range
|
|
4152
|
+
or an array with the lower and upper translation limits.
|
|
4153
|
+
"""
|
|
4154
|
+
...
|
|
4155
|
+
|
|
4156
|
+
@range.setter
|
|
4157
|
+
def range(self, val: tuple[float, float] | float) -> None: ...
|
|
4158
|
+
|
|
4159
|
+
@property
|
|
4160
|
+
def springEnabled(self) -> bool:
|
|
4161
|
+
"""
|
|
4162
|
+
Whether spring behavior is enabled.
|
|
4163
|
+
|
|
4164
|
+
Default: `false`
|
|
4165
|
+
"""
|
|
4166
|
+
...
|
|
4167
|
+
|
|
4168
|
+
@springEnabled.setter
|
|
4169
|
+
def springEnabled(self, val: bool) -> None: ...
|
|
4170
|
+
|
|
4171
|
+
@property
|
|
4172
|
+
def springiness(self) -> float:
|
|
4173
|
+
"""
|
|
4174
|
+
The springiness of the joint, a 0-1 ratio.
|
|
4175
|
+
|
|
4176
|
+
0 is rigid, 0.5 is bouncy, 1 is loose.
|
|
4177
|
+
|
|
4178
|
+
Default: `0`
|
|
4179
|
+
"""
|
|
4180
|
+
...
|
|
4181
|
+
|
|
4182
|
+
@springiness.setter
|
|
4183
|
+
def springiness(self, val: float) -> None: ...
|
|
4184
|
+
|
|
4185
|
+
@property
|
|
4186
|
+
def damping(self) -> float:
|
|
4187
|
+
"""
|
|
4188
|
+
Damping ratio, 0-1. Higher values reduce oscillation faster.
|
|
4189
|
+
|
|
4190
|
+
Default: `0`
|
|
4191
|
+
"""
|
|
4192
|
+
...
|
|
4193
|
+
|
|
4194
|
+
@damping.setter
|
|
4195
|
+
def damping(self, val: float) -> None: ...
|
|
4196
|
+
|
|
4197
|
+
@property
|
|
4198
|
+
def motorEnabled(self) -> bool:
|
|
4199
|
+
"""
|
|
4200
|
+
Whether the joint's motor is enabled.
|
|
4201
|
+
|
|
4202
|
+
Default: `true`
|
|
4203
|
+
"""
|
|
4204
|
+
...
|
|
4205
|
+
|
|
4206
|
+
@motorEnabled.setter
|
|
4207
|
+
def motorEnabled(self, val: bool) -> None: ...
|
|
4208
|
+
|
|
4209
|
+
@property
|
|
4210
|
+
def speed(self) -> float:
|
|
4211
|
+
"""
|
|
4212
|
+
Motor speed.
|
|
4213
|
+
|
|
4214
|
+
Default: `0`
|
|
4215
|
+
"""
|
|
4216
|
+
...
|
|
4217
|
+
|
|
4218
|
+
@speed.setter
|
|
4219
|
+
def speed(self, val: float) -> None: ...
|
|
4220
|
+
|
|
4221
|
+
@property
|
|
4222
|
+
def maxPower(self) -> float:
|
|
4223
|
+
"""
|
|
4224
|
+
Maximum force the motor can apply.
|
|
4225
|
+
|
|
4226
|
+
Default: `10`
|
|
4227
|
+
"""
|
|
4228
|
+
...
|
|
4229
|
+
|
|
4230
|
+
@maxPower.setter
|
|
4231
|
+
def maxPower(self, val: float) -> None: ...
|
|
4232
|
+
|
|
4233
|
+
@property
|
|
4234
|
+
def power(self) -> float:
|
|
4235
|
+
"""The current motor force being applied."""
|
|
4236
|
+
...
|
|
4237
|
+
|
|
4238
|
+
@property
|
|
4239
|
+
def energy(self) -> float:
|
|
4240
|
+
"""The current sliding speed of the joint."""
|
|
4241
|
+
...
|
|
4242
|
+
|
|
4243
|
+
class GrabberJoint(Joint):
|
|
4244
|
+
|
|
4245
|
+
def __init__(self, pointer: Any, sprite: Sprite) -> None: ...
|
|
4246
|
+
|
|
4247
|
+
sprite: Sprite
|
|
4248
|
+
"""The sprite being grabbed by the joint."""
|
|
4249
|
+
|
|
4250
|
+
@property
|
|
4251
|
+
def target(self) -> Any:
|
|
4252
|
+
"""
|
|
4253
|
+
The target position of the joint that the sprite will be
|
|
4254
|
+
moved towards. Can be a coordinate array or object with x and y properties.
|
|
4255
|
+
"""
|
|
4256
|
+
...
|
|
4257
|
+
|
|
4258
|
+
@target.setter
|
|
4259
|
+
def target(self, val: Any) -> None: ...
|
|
4260
|
+
|
|
4261
|
+
@property
|
|
4262
|
+
def maxForce(self) -> float:
|
|
4263
|
+
"""
|
|
4264
|
+
The maximum spring force that the joint can exert on the sprite.
|
|
4265
|
+
|
|
4266
|
+
By default it's 500 * the sprite's mass.
|
|
4267
|
+
"""
|
|
4268
|
+
...
|
|
4269
|
+
|
|
4270
|
+
@maxForce.setter
|
|
4271
|
+
def maxForce(self, val: float) -> None: ...
|
|
4272
|
+
|
|
4273
|
+
@property
|
|
4274
|
+
def maxTorque(self) -> float:
|
|
4275
|
+
"""
|
|
4276
|
+
The maximum torque that the joint can exert on the sprite.
|
|
4277
|
+
|
|
4278
|
+
By default it's 0.25 * the sprite's mass * the square root
|
|
4279
|
+
of the rotational inertia divided by the sprite's mass.
|
|
4280
|
+
"""
|
|
4281
|
+
...
|
|
4282
|
+
|
|
4283
|
+
@maxTorque.setter
|
|
4284
|
+
def maxTorque(self, val: float) -> None: ...
|
|
4285
|
+
|
|
4286
|
+
class CastInfo:
|
|
4287
|
+
|
|
4288
|
+
sprite: Sprite
|
|
4289
|
+
"""The sprite that was hit by the ray or circle cast."""
|
|
4290
|
+
|
|
4291
|
+
distance: float
|
|
4292
|
+
"""The distance from the start of the cast to the intersection point."""
|
|
4293
|
+
|
|
4294
|
+
@property
|
|
4295
|
+
def intersect(self) -> dict:
|
|
4296
|
+
"""The intersection point of the cast with the sprite's shape."""
|
|
4297
|
+
...
|
|
4298
|
+
|
|
4299
|
+
@property
|
|
4300
|
+
def incidence(self) -> float:
|
|
4301
|
+
"""The angle of incidence of the cast at the intersection point."""
|
|
4302
|
+
...
|
|
4303
|
+
|
|
4304
|
+
class Scale:
|
|
4305
|
+
|
|
4306
|
+
def valueOf(self) -> float:
|
|
4307
|
+
...
|
|
4308
|
+
|
|
4309
|
+
class FriendlyError(Exception):
|
|
4310
|
+
"""
|
|
4311
|
+
A FriendlyError is a custom error class that extends the native JS
|
|
4312
|
+
Error class. It's used internally by q5play to make error messages
|
|
4313
|
+
more helpful.
|
|
4314
|
+
"""
|
|
4315
|
+
|
|
4316
|
+
@classmethod
|
|
4317
|
+
def new(cls, func: Any, errorNum: Any, e: Any) -> 'FriendlyError':
|
|
4318
|
+
...
|
|
4319
|
+
|
|
4320
|
+
def __init__(self, func: Any, errorNum: Any, e: Any) -> None: ...
|
|
4321
|
+
|
|
4322
|
+
class InputDevice:
|
|
4323
|
+
|
|
4324
|
+
holdThreshold: float
|
|
4325
|
+
"""
|
|
4326
|
+
The amount of frames an input must be pressed to be considered held.
|
|
4327
|
+
|
|
4328
|
+
Default: `12`
|
|
4329
|
+
"""
|
|
4330
|
+
|
|
4331
|
+
def presses(self, inp: str = ...) -> bool:
|
|
4332
|
+
"""
|
|
4333
|
+
|
|
4334
|
+
Returns:
|
|
4335
|
+
true on the first frame that the user presses the input
|
|
4336
|
+
"""
|
|
4337
|
+
...
|
|
4338
|
+
|
|
4339
|
+
def pressing(self, inp: str = ...) -> float:
|
|
4340
|
+
"""
|
|
4341
|
+
|
|
4342
|
+
Returns:
|
|
4343
|
+
the amount of frames the user has been pressing the input
|
|
4344
|
+
"""
|
|
4345
|
+
...
|
|
4346
|
+
|
|
4347
|
+
def pressed(self, inp: str = ...) -> bool:
|
|
4348
|
+
"""
|
|
4349
|
+
Same as the `released` function, which is preferred.
|
|
4350
|
+
|
|
4351
|
+
.. deprecated::
|
|
4352
|
+
|
|
4353
|
+
Returns:
|
|
4354
|
+
true on the first frame that the user released the input
|
|
4355
|
+
"""
|
|
4356
|
+
...
|
|
4357
|
+
|
|
4358
|
+
def holds(self, inp: str = ...) -> bool:
|
|
4359
|
+
"""
|
|
4360
|
+
|
|
4361
|
+
Returns:
|
|
4362
|
+
true on the first frame that the user holds the input
|
|
4363
|
+
"""
|
|
4364
|
+
...
|
|
4365
|
+
|
|
4366
|
+
def holding(self, inp: str = ...) -> float:
|
|
4367
|
+
"""
|
|
4368
|
+
|
|
4369
|
+
Returns:
|
|
4370
|
+
the amount of frames the user has been holding the input
|
|
4371
|
+
"""
|
|
4372
|
+
...
|
|
4373
|
+
|
|
4374
|
+
def held(self, inp: str = ...) -> bool:
|
|
4375
|
+
"""
|
|
4376
|
+
|
|
4377
|
+
Returns:
|
|
4378
|
+
true on the first frame that the user released a held input
|
|
4379
|
+
"""
|
|
4380
|
+
...
|
|
4381
|
+
|
|
4382
|
+
def released(self, inp: str = ...) -> bool:
|
|
4383
|
+
"""
|
|
4384
|
+
|
|
4385
|
+
Returns:
|
|
4386
|
+
true on the first frame that the user released the input
|
|
4387
|
+
"""
|
|
4388
|
+
...
|
|
4389
|
+
|
|
4390
|
+
def releases(self, inp: Any = ...) -> bool:
|
|
4391
|
+
...
|
|
4392
|
+
|
|
4393
|
+
class _Mouse(InputDevice):
|
|
4394
|
+
|
|
4395
|
+
x: float
|
|
4396
|
+
"""The mouse's x position in the world."""
|
|
4397
|
+
|
|
4398
|
+
y: float
|
|
4399
|
+
"""The mouse's y position in the world."""
|
|
4400
|
+
|
|
4401
|
+
canvasPos: dict
|
|
4402
|
+
"""The mouse's absolute position on the canvas."""
|
|
4403
|
+
|
|
4404
|
+
left: float
|
|
4405
|
+
"""The mouse's left button."""
|
|
4406
|
+
|
|
4407
|
+
center: float
|
|
4408
|
+
"""The mouse's center button."""
|
|
4409
|
+
|
|
4410
|
+
right: float
|
|
4411
|
+
"""The mouse's right button."""
|
|
4412
|
+
|
|
4413
|
+
scrollDelta: dict
|
|
4414
|
+
"""Contains the scroll status of the mouse wheel."""
|
|
4415
|
+
|
|
4416
|
+
drag: dict
|
|
4417
|
+
"""Contains the drag status of each of the mouse's buttons."""
|
|
4418
|
+
|
|
4419
|
+
isOnCanvas: bool
|
|
4420
|
+
"""
|
|
4421
|
+
True if the mouse is currently on the canvas.
|
|
4422
|
+
|
|
4423
|
+
Default: `false`
|
|
4424
|
+
"""
|
|
4425
|
+
|
|
4426
|
+
isActive: bool
|
|
4427
|
+
"""
|
|
4428
|
+
True if the mouse has ever interacted with the canvas.
|
|
4429
|
+
|
|
4430
|
+
Default: `false`
|
|
4431
|
+
"""
|
|
4432
|
+
|
|
4433
|
+
@property
|
|
4434
|
+
def pos(self) -> dict:
|
|
4435
|
+
"""
|
|
4436
|
+
Gets the mouse's current position in the world as a readonly object {x, y}
|
|
4437
|
+
that won't updated if the mouse moves.
|
|
4438
|
+
"""
|
|
4439
|
+
...
|
|
4440
|
+
|
|
4441
|
+
@property
|
|
4442
|
+
def position(self) -> dict:
|
|
4443
|
+
"""The mouse's current position."""
|
|
4444
|
+
...
|
|
4445
|
+
|
|
4446
|
+
@property
|
|
4447
|
+
def cursor(self) -> str:
|
|
4448
|
+
"""
|
|
4449
|
+
The mouse's CSS cursor style.
|
|
4450
|
+
|
|
4451
|
+
Default: `'default'`
|
|
4452
|
+
"""
|
|
4453
|
+
...
|
|
4454
|
+
|
|
4455
|
+
@cursor.setter
|
|
4456
|
+
def cursor(self, val: str) -> None: ...
|
|
4457
|
+
|
|
4458
|
+
@property
|
|
4459
|
+
def visible(self) -> bool:
|
|
4460
|
+
"""
|
|
4461
|
+
Controls whether the mouse is visible or not.
|
|
4462
|
+
|
|
4463
|
+
Default: `true`
|
|
4464
|
+
"""
|
|
4465
|
+
...
|
|
4466
|
+
|
|
4467
|
+
@visible.setter
|
|
4468
|
+
def visible(self, val: bool) -> None: ...
|
|
4469
|
+
|
|
4470
|
+
def drags(self, inp: str = ...) -> bool:
|
|
4471
|
+
"""
|
|
4472
|
+
|
|
4473
|
+
Returns:
|
|
4474
|
+
true on the first frame that the user moves the mouse while pressing the input
|
|
4475
|
+
"""
|
|
4476
|
+
...
|
|
4477
|
+
|
|
4478
|
+
def dragging(self, inp: str = ...) -> float:
|
|
4479
|
+
"""
|
|
4480
|
+
|
|
4481
|
+
Returns:
|
|
4482
|
+
the amount of frames the user has been moving the mouse while pressing the input
|
|
4483
|
+
"""
|
|
4484
|
+
...
|
|
4485
|
+
|
|
4486
|
+
def dragged(self, inp: str = ...) -> bool:
|
|
4487
|
+
"""
|
|
4488
|
+
|
|
4489
|
+
Returns:
|
|
4490
|
+
true on the first frame that the user releases the input after dragging the mouse
|
|
4491
|
+
"""
|
|
4492
|
+
...
|
|
4493
|
+
|
|
4494
|
+
def scrolls(self) -> bool:
|
|
4495
|
+
"""
|
|
4496
|
+
|
|
4497
|
+
Returns:
|
|
4498
|
+
true on the first frame that the user scrolls the mouse wheel
|
|
4499
|
+
"""
|
|
4500
|
+
...
|
|
4501
|
+
|
|
4502
|
+
def scrolling(self) -> float:
|
|
4503
|
+
"""
|
|
4504
|
+
|
|
4505
|
+
Returns:
|
|
4506
|
+
the amount of frames the user has been scrolling the mouse wheel
|
|
4507
|
+
"""
|
|
4508
|
+
...
|
|
4509
|
+
|
|
4510
|
+
def scrolled(self) -> bool:
|
|
4511
|
+
"""
|
|
4512
|
+
|
|
4513
|
+
Returns:
|
|
4514
|
+
true on the first frame that the user stops scrolling the mouse wheel
|
|
4515
|
+
"""
|
|
4516
|
+
...
|
|
4517
|
+
|
|
4518
|
+
class _Pointer(InputDevice):
|
|
4519
|
+
|
|
4520
|
+
@classmethod
|
|
4521
|
+
def new(cls, pointer: Any) -> '_Pointer':
|
|
4522
|
+
...
|
|
4523
|
+
|
|
4524
|
+
def __init__(self, pointer: Any) -> None: ...
|
|
4525
|
+
|
|
4526
|
+
x: float
|
|
4527
|
+
"""The pointer's x position in the physics world."""
|
|
4528
|
+
|
|
4529
|
+
y: float
|
|
4530
|
+
"""The pointer's y position in the physics world."""
|
|
4531
|
+
|
|
4532
|
+
id: float
|
|
4533
|
+
"""The pointer's unique identifier."""
|
|
4534
|
+
|
|
4535
|
+
duration: float
|
|
4536
|
+
"""The amount of frames the pointer has been active for."""
|
|
4537
|
+
|
|
4538
|
+
canvasPos: dict
|
|
4539
|
+
"""The pointer's absolute position on the canvas."""
|
|
4540
|
+
|
|
4541
|
+
pressure: float
|
|
4542
|
+
"""
|
|
4543
|
+
The pointer's pressure level, from 0 to 1.
|
|
4544
|
+
|
|
4545
|
+
On devices that do not support pressure sensitivity,
|
|
4546
|
+
the value is 0.5 when the pointer is pressing.
|
|
4547
|
+
"""
|
|
4548
|
+
|
|
4549
|
+
press: float
|
|
4550
|
+
"""
|
|
4551
|
+
The amount of frames the user has been clicking, touching,
|
|
4552
|
+
or drawing on the screen with the pointer.
|
|
4553
|
+
"""
|
|
4554
|
+
|
|
4555
|
+
def grabs(self) -> bool:
|
|
4556
|
+
"""
|
|
4557
|
+
|
|
4558
|
+
Returns:
|
|
4559
|
+
true on the first frame that the pointer grabs a sprite
|
|
4560
|
+
"""
|
|
4561
|
+
...
|
|
4562
|
+
|
|
4563
|
+
def grabbing(self) -> float:
|
|
4564
|
+
"""
|
|
4565
|
+
|
|
4566
|
+
Returns:
|
|
4567
|
+
the amount of frames the pointer has been grabbing a sprite
|
|
4568
|
+
"""
|
|
4569
|
+
...
|
|
4570
|
+
|
|
4571
|
+
def grabbed(self) -> bool:
|
|
4572
|
+
"""
|
|
4573
|
+
|
|
4574
|
+
Returns:
|
|
4575
|
+
true on the first frame that the pointer releases a grabbed sprite
|
|
4576
|
+
"""
|
|
4577
|
+
...
|
|
4578
|
+
|
|
4579
|
+
def overlaps(self, sprite: Sprite) -> bool:
|
|
4580
|
+
"""
|
|
4581
|
+
|
|
4582
|
+
Returns:
|
|
4583
|
+
true on the first frame that the pointer overlaps the sprite
|
|
4584
|
+
"""
|
|
4585
|
+
...
|
|
4586
|
+
|
|
4587
|
+
def overlapping(self, sprite: Sprite) -> float:
|
|
4588
|
+
"""
|
|
4589
|
+
|
|
4590
|
+
Returns:
|
|
4591
|
+
the amount of frames the pointer has been overlapping the sprite
|
|
4592
|
+
"""
|
|
4593
|
+
...
|
|
4594
|
+
|
|
4595
|
+
def overlapped(self, sprite: Sprite) -> bool:
|
|
4596
|
+
"""
|
|
4597
|
+
|
|
4598
|
+
Returns:
|
|
4599
|
+
true on the first frame that the pointer stops overlapping the sprite
|
|
4600
|
+
"""
|
|
4601
|
+
...
|
|
4602
|
+
|
|
4603
|
+
class _Keyboard(InputDevice):
|
|
4604
|
+
|
|
4605
|
+
alt: float
|
|
4606
|
+
|
|
4607
|
+
arrowUp: float
|
|
4608
|
+
|
|
4609
|
+
arrowDown: float
|
|
4610
|
+
|
|
4611
|
+
arrowLeft: float
|
|
4612
|
+
|
|
4613
|
+
arrowRight: float
|
|
4614
|
+
|
|
4615
|
+
backspace: float
|
|
4616
|
+
|
|
4617
|
+
capsLock: float
|
|
4618
|
+
|
|
4619
|
+
control: float
|
|
4620
|
+
|
|
4621
|
+
enter: float
|
|
4622
|
+
|
|
4623
|
+
meta: float
|
|
4624
|
+
|
|
4625
|
+
shift: float
|
|
4626
|
+
|
|
4627
|
+
tab: float
|
|
4628
|
+
|
|
4629
|
+
@property
|
|
4630
|
+
def visible(self) -> bool:
|
|
4631
|
+
...
|
|
4632
|
+
|
|
4633
|
+
@visible.setter
|
|
4634
|
+
def visible(self, val: bool) -> None: ...
|
|
4635
|
+
|
|
4636
|
+
@property
|
|
4637
|
+
def cmd(self) -> float:
|
|
4638
|
+
...
|
|
4639
|
+
|
|
4640
|
+
@property
|
|
4641
|
+
def command(self) -> float:
|
|
4642
|
+
...
|
|
4643
|
+
|
|
4644
|
+
@property
|
|
4645
|
+
def ctrl(self) -> float:
|
|
4646
|
+
...
|
|
4647
|
+
|
|
4648
|
+
@property
|
|
4649
|
+
def space(self) -> Any:
|
|
4650
|
+
...
|
|
4651
|
+
|
|
4652
|
+
@property
|
|
4653
|
+
def opt(self) -> float:
|
|
4654
|
+
...
|
|
4655
|
+
|
|
4656
|
+
@property
|
|
4657
|
+
def option(self) -> float:
|
|
4658
|
+
...
|
|
4659
|
+
|
|
4660
|
+
@property
|
|
4661
|
+
def win(self) -> float:
|
|
4662
|
+
...
|
|
4663
|
+
|
|
4664
|
+
@property
|
|
4665
|
+
def windows(self) -> float:
|
|
4666
|
+
...
|
|
4667
|
+
|
|
4668
|
+
class Contro(InputDevice):
|
|
4669
|
+
|
|
4670
|
+
@classmethod
|
|
4671
|
+
def new(cls, gp: Any | str) -> 'Contro':
|
|
4672
|
+
"""
|
|
4673
|
+
Stores the input status of buttons, triggers, and sticks on
|
|
4674
|
+
game controllers. Used internally to create controller objects
|
|
4675
|
+
for the `contros` array (aka `controllers`).
|
|
4676
|
+
|
|
4677
|
+
Can also be used to create a mock controller object.
|
|
4678
|
+
"""
|
|
4679
|
+
...
|
|
4680
|
+
|
|
4681
|
+
def __init__(self, gp: Any | str) -> None: ...
|
|
4682
|
+
|
|
4683
|
+
connected: bool
|
|
4684
|
+
|
|
4685
|
+
a: float
|
|
4686
|
+
|
|
4687
|
+
b: float
|
|
4688
|
+
|
|
4689
|
+
x: float
|
|
4690
|
+
|
|
4691
|
+
y: float
|
|
4692
|
+
|
|
4693
|
+
l: float
|
|
4694
|
+
"""Left shoulder button."""
|
|
4695
|
+
|
|
4696
|
+
r: float
|
|
4697
|
+
"""Right shoulder button."""
|
|
4698
|
+
|
|
4699
|
+
lt: float
|
|
4700
|
+
"""Digital left trigger."""
|
|
4701
|
+
|
|
4702
|
+
rt: float
|
|
4703
|
+
"""Digital right trigger."""
|
|
4704
|
+
|
|
4705
|
+
select: float
|
|
4706
|
+
|
|
4707
|
+
start: float
|
|
4708
|
+
|
|
4709
|
+
lsb: float
|
|
4710
|
+
"""
|
|
4711
|
+
Left stick button.
|
|
4712
|
+
Activated by pressing down on the left analog stick.
|
|
4713
|
+
"""
|
|
4714
|
+
|
|
4715
|
+
rsb: float
|
|
4716
|
+
"""
|
|
4717
|
+
Right stick button.
|
|
4718
|
+
Activated by pressing down on the right analog stick.
|
|
4719
|
+
"""
|
|
4720
|
+
|
|
4721
|
+
up: float
|
|
4722
|
+
|
|
4723
|
+
down: float
|
|
4724
|
+
|
|
4725
|
+
left: float
|
|
4726
|
+
|
|
4727
|
+
right: float
|
|
4728
|
+
|
|
4729
|
+
leftStick: Any
|
|
4730
|
+
"""
|
|
4731
|
+
Has x and y properties with -1 to 1 values which
|
|
4732
|
+
represent the position of the left analog stick.
|
|
4733
|
+
|
|
4734
|
+
{x: 0, y: 0} is the center position.
|
|
4735
|
+
"""
|
|
4736
|
+
|
|
4737
|
+
rightStick: Any
|
|
4738
|
+
"""
|
|
4739
|
+
Has x and y properties with -1 to 1 values which
|
|
4740
|
+
represent the position of the right analog stick.
|
|
4741
|
+
|
|
4742
|
+
{x: 0, y: 0} is the center position.
|
|
4743
|
+
"""
|
|
4744
|
+
|
|
4745
|
+
leftTrigger: float
|
|
4746
|
+
"""
|
|
4747
|
+
Analog value 0-1 of the left trigger.
|
|
4748
|
+
|
|
4749
|
+
Default: `0`
|
|
4750
|
+
"""
|
|
4751
|
+
|
|
4752
|
+
rightTrigger: float
|
|
4753
|
+
"""
|
|
4754
|
+
Analog value 0-1 of the right trigger.
|
|
4755
|
+
|
|
4756
|
+
Default: `0`
|
|
4757
|
+
"""
|
|
4758
|
+
|
|
4759
|
+
buttonMapping: Any
|
|
4760
|
+
"""Button names are mapped to `gamepad.buttons` indices."""
|
|
4761
|
+
|
|
4762
|
+
axeMapping: Any
|
|
4763
|
+
"""Sticks and triggers are mapped to `gamepad.axes` indices."""
|
|
4764
|
+
|
|
4765
|
+
isMock: bool
|
|
4766
|
+
"""If the controller is a mock controller."""
|
|
4767
|
+
|
|
4768
|
+
gamepad: Any
|
|
4769
|
+
|
|
4770
|
+
id: Any
|
|
4771
|
+
|
|
4772
|
+
hasAnalogTriggers: bool
|
|
4773
|
+
"""
|
|
4774
|
+
True if the controller has analog triggers.
|
|
4775
|
+
False if the controller has digital (button) triggers.
|
|
4776
|
+
"""
|
|
4777
|
+
|
|
4778
|
+
@property
|
|
4779
|
+
def cross(self) -> float:
|
|
4780
|
+
...
|
|
4781
|
+
|
|
4782
|
+
@property
|
|
4783
|
+
def circle(self) -> float:
|
|
4784
|
+
...
|
|
4785
|
+
|
|
4786
|
+
@property
|
|
4787
|
+
def square(self) -> float:
|
|
4788
|
+
...
|
|
4789
|
+
|
|
4790
|
+
@property
|
|
4791
|
+
def triangle(self) -> float:
|
|
4792
|
+
...
|
|
4793
|
+
|
|
4794
|
+
@property
|
|
4795
|
+
def ls(self) -> Any:
|
|
4796
|
+
"""Alias for `leftStick`."""
|
|
4797
|
+
...
|
|
4798
|
+
|
|
4799
|
+
@property
|
|
4800
|
+
def rs(self) -> Any:
|
|
4801
|
+
"""Alias for `rightStick`."""
|
|
4802
|
+
...
|
|
4803
|
+
|
|
4804
|
+
@property
|
|
4805
|
+
def lb(self) -> float:
|
|
4806
|
+
"""
|
|
4807
|
+
Alias for `l` (left shoulder button).
|
|
4808
|
+
`lb` is what it's called on Xbox controllers.
|
|
4809
|
+
"""
|
|
4810
|
+
...
|
|
4811
|
+
|
|
4812
|
+
@property
|
|
4813
|
+
def rb(self) -> float:
|
|
4814
|
+
"""
|
|
4815
|
+
Alias for `r` (right shoulder button).
|
|
4816
|
+
`rb` is what it's called on Xbox controllers.
|
|
4817
|
+
"""
|
|
4818
|
+
...
|
|
4819
|
+
|
|
4820
|
+
@property
|
|
4821
|
+
def l1(self) -> float:
|
|
4822
|
+
"""
|
|
4823
|
+
Alias for `l` (left shoulder button).
|
|
4824
|
+
`l1` is what it's called on PlayStation controllers.
|
|
4825
|
+
"""
|
|
4826
|
+
...
|
|
4827
|
+
|
|
4828
|
+
@property
|
|
4829
|
+
def r1(self) -> float:
|
|
4830
|
+
"""
|
|
4831
|
+
Alias for `r` (right shoulder button).
|
|
4832
|
+
`r1` is what it's called on PlayStation controllers.
|
|
4833
|
+
"""
|
|
4834
|
+
...
|
|
4835
|
+
|
|
4836
|
+
@property
|
|
4837
|
+
def zl(self) -> float:
|
|
4838
|
+
"""
|
|
4839
|
+
Alias for `lt` (digital left trigger).
|
|
4840
|
+
`zl` is what it's called on Nintendo controllers.
|
|
4841
|
+
"""
|
|
4842
|
+
...
|
|
4843
|
+
|
|
4844
|
+
@property
|
|
4845
|
+
def zr(self) -> float:
|
|
4846
|
+
"""
|
|
4847
|
+
Alias for `rt` (digital right trigger).
|
|
4848
|
+
`zr` is what it's called on Nintendo controllers.
|
|
4849
|
+
"""
|
|
4850
|
+
...
|
|
4851
|
+
|
|
4852
|
+
@property
|
|
4853
|
+
def l2(self) -> float:
|
|
4854
|
+
"""
|
|
4855
|
+
Alias for `leftTrigger` (analog left trigger).
|
|
4856
|
+
`l2` is what it's called on PlayStation controllers.
|
|
4857
|
+
"""
|
|
4858
|
+
...
|
|
4859
|
+
|
|
4860
|
+
@property
|
|
4861
|
+
def r2(self) -> float:
|
|
4862
|
+
"""
|
|
4863
|
+
Alias for `rightTrigger` (analog right trigger).
|
|
4864
|
+
`r2` is what it's called on PlayStation controllers.
|
|
4865
|
+
"""
|
|
4866
|
+
...
|
|
4867
|
+
|
|
4868
|
+
@property
|
|
4869
|
+
def leftStickButton(self) -> float:
|
|
4870
|
+
"""Verbose alias for `lsb`."""
|
|
4871
|
+
...
|
|
4872
|
+
|
|
4873
|
+
@property
|
|
4874
|
+
def rightStickButton(self) -> float:
|
|
4875
|
+
"""Verbose alias for `rsb`."""
|
|
4876
|
+
...
|
|
4877
|
+
|
|
4878
|
+
@property
|
|
4879
|
+
def l3(self) -> float:
|
|
4880
|
+
"""
|
|
4881
|
+
Alias for `lsb` (left stick button).
|
|
4882
|
+
`l3` is what it's called on PlayStation controllers.
|
|
4883
|
+
"""
|
|
4884
|
+
...
|
|
4885
|
+
|
|
4886
|
+
@property
|
|
4887
|
+
def r3(self) -> float:
|
|
4888
|
+
"""
|
|
4889
|
+
Alias for `rsb` (right stick button).
|
|
4890
|
+
`r3` is what it's called on PlayStation controllers.
|
|
4891
|
+
"""
|
|
4892
|
+
...
|
|
4893
|
+
|
|
4894
|
+
class _Contros(list[Contro]):
|
|
4895
|
+
|
|
4896
|
+
@classmethod
|
|
4897
|
+
def new(cls) -> '_Contros':
|
|
4898
|
+
"""
|
|
4899
|
+
Used internally to create the `contros` array (aka `controllers`)
|
|
4900
|
+
of `Contro` objects, which store the input status of buttons,
|
|
4901
|
+
triggers, and sticks on game controllers.
|
|
4902
|
+
"""
|
|
4903
|
+
...
|
|
4904
|
+
|
|
4905
|
+
def __init__(self) -> None: ...
|
|
4906
|
+
|
|
4907
|
+
def swap(self, indexA: float, indexB: float) -> None:
|
|
4908
|
+
"""Swap controller positions in this controllers array."""
|
|
4909
|
+
...
|
|
4910
|
+
|
|
4911
|
+
def remove(self, index: float) -> None: # type: ignore[override]
|
|
4912
|
+
"""
|
|
4913
|
+
Removes a controller from this controllers array
|
|
4914
|
+
by setting `contros[index] = null`.
|
|
4915
|
+
|
|
4916
|
+
Newly connected controllers fill the first empty slot.
|
|
4917
|
+
"""
|
|
4918
|
+
...
|
|
4919
|
+
|
|
4920
|
+
def onConnect(self, gamepad: Any) -> bool:
|
|
4921
|
+
"""
|
|
4922
|
+
Runs when a controller is connected. By default it
|
|
4923
|
+
always returns true. Overwrite this function to customize
|
|
4924
|
+
the behavior.
|
|
4925
|
+
|
|
4926
|
+
For example, it could be customized to filter
|
|
4927
|
+
controllers based on their model info.
|
|
4928
|
+
|
|
4929
|
+
Doesn't run if a controller in the `controllers` array
|
|
4930
|
+
is reconnected.
|
|
4931
|
+
|
|
4932
|
+
Returns:
|
|
4933
|
+
true if the controller should be added to this q5play controllers array
|
|
4934
|
+
"""
|
|
4935
|
+
...
|
|
4936
|
+
|
|
4937
|
+
def onDisconnect(self, gamepad: Any) -> bool:
|
|
4938
|
+
"""
|
|
4939
|
+
Runs when a controller is disconnected. by default it
|
|
4940
|
+
always returns false. Overwrite this function to customize
|
|
4941
|
+
the behavior.
|
|
4942
|
+
|
|
4943
|
+
Removing a controller from the `controllers` array
|
|
4944
|
+
usually is not desirable, because the controller could be
|
|
4945
|
+
reconnected later. By default, the controller is kept in
|
|
4946
|
+
the array and its state is reset.
|
|
4947
|
+
|
|
4948
|
+
Returns:
|
|
4949
|
+
true if the controllers should be removed from this q5play controllers array
|
|
4950
|
+
"""
|
|
4951
|
+
...
|
|
4952
|
+
|
|
4953
|
+
def colorPal(c: str, palette: list[dict | str]) -> str:
|
|
4954
|
+
...
|
|
4955
|
+
|
|
4956
|
+
def EmojiImage(emoji: str, textSize: float) -> Image:
|
|
4957
|
+
...
|
|
4958
|
+
|
|
4959
|
+
def spriteArt(txt: str, scale: float, palette: list[dict | str]) -> Image:
|
|
4960
|
+
...
|
|
4961
|
+
|
|
4962
|
+
def animation(ani: Ani, x: float, y: float, dW: float, dH: float) -> None:
|
|
4963
|
+
"""
|
|
4964
|
+
Draws an animation.
|
|
4965
|
+
|
|
4966
|
+
Args:
|
|
4967
|
+
ani: the animation
|
|
4968
|
+
x: x coordinate to draw the animation at
|
|
4969
|
+
y: y coordinate to draw the animation at
|
|
4970
|
+
dW: display width
|
|
4971
|
+
dH: display height
|
|
4972
|
+
"""
|
|
4973
|
+
...
|
|
4974
|
+
|
|
4975
|
+
def delay(milliseconds: float = ...) -> Awaitable[None]:
|
|
4976
|
+
"""
|
|
4977
|
+
|
|
4978
|
+
Args:
|
|
4979
|
+
milliseconds: if not specified, delays until the next frame draw
|
|
4980
|
+
|
|
4981
|
+
Returns:
|
|
4982
|
+
resolves after the delay
|
|
4983
|
+
"""
|
|
4984
|
+
...
|
|
4985
|
+
|
|
4986
|
+
allSprites: Group
|
|
4987
|
+
|
|
4988
|
+
world: World
|
|
4989
|
+
|
|
4990
|
+
camera: Camera
|
|
4991
|
+
|
|
4992
|
+
mouse: _Mouse
|
|
4993
|
+
|
|
4994
|
+
pointers: list[_Pointer]
|
|
4995
|
+
|
|
4996
|
+
pointer: _Pointer
|
|
4997
|
+
|
|
4998
|
+
kb: _Keyboard
|
|
4999
|
+
|
|
5000
|
+
keyboard: _Keyboard
|
|
5001
|
+
|
|
5002
|
+
contros: _Contros
|
|
5003
|
+
|
|
5004
|
+
controllers: _Contros
|
|
5005
|
+
|
|
5006
|
+
contro: Contro
|
|
5007
|
+
|