@defold-typescript/library-types 0.18.1
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/NOTICE +52 -0
- package/README.md +78 -0
- package/api-doc/boom.boom.json +26 -0
- package/api-doc/bridge.bridge.json +1653 -0
- package/api-doc/bzAnim.bzLibrary.json +156 -0
- package/api-doc/defcon.console.json +109 -0
- package/api-doc/defmath.defmath.json +1381 -0
- package/api-doc/defsave.defsave.json +175 -0
- package/api-doc/deftest.deftest.json +71 -0
- package/api-doc/dicebag.dicebag.json +323 -0
- package/api-doc/event.event.json +238 -0
- package/api-doc/gooey.gooey.json +963 -0
- package/api-doc/immutable.immutable.json +63 -0
- package/api-doc/in.accelerometer.json +281 -0
- package/api-doc/in.button.json +148 -0
- package/api-doc/in.cursor.json +203 -0
- package/api-doc/in.gesture.json +206 -0
- package/api-doc/in.keyboard.json +45 -0
- package/api-doc/in.mapper.json +141 -0
- package/api-doc/in.onscreen.json +265 -0
- package/api-doc/in.state.json +195 -0
- package/api-doc/in.textbox.json +213 -0
- package/api-doc/in.triggers.json +1260 -0
- package/api-doc/lang.lang.json +411 -0
- package/api-doc/log.log.json +50 -0
- package/api-doc/metrics.fps.json +88 -0
- package/api-doc/metrics.mem.json +80 -0
- package/api-doc/monarch.monarch.json +1065 -0
- package/api-doc/monarch.transitions.easings.json +206 -0
- package/api-doc/monarch.transitions.gui.json +445 -0
- package/api-doc/nakama.engine.defold.json +165 -0
- package/api-doc/nakama.nakama.json +6574 -0
- package/api-doc/nakama.util.log.json +25 -0
- package/api-doc/narrator.narrator.json +150 -0
- package/api-doc/orthographic.camera.json +1019 -0
- package/api-doc/persist.persist.json +142 -0
- package/api-doc/platypus.platypus.json +631 -0
- package/api-doc/proto.proto.json +355 -0
- package/api-doc/rendy.rendy.json +408 -0
- package/api-doc/richtext.color.json +219 -0
- package/api-doc/richtext.richtext.json +382 -0
- package/api-doc/richtext.tags.json +67 -0
- package/api-doc/saver.saver.json +553 -0
- package/api-doc/saver.storage.json +174 -0
- package/api-doc/squid.squid.json +660 -0
- package/api-doc/starly.starly.json +488 -0
- package/api-doc/tweener.tweener.json +419 -0
- package/api-doc/yagames.yagames.json +1465 -0
- package/api-doc/zzfx.api.json +85 -0
- package/generated/boom.boom.d.ts +1585 -0
- package/generated/bridge.bridge.d.ts +533 -0
- package/generated/bzAnim.bzLibrary.d.ts +93 -0
- package/generated/defcon.console.d.ts +24 -0
- package/generated/defmath.defmath.d.ts +194 -0
- package/generated/defsave.defsave.d.ts +31 -0
- package/generated/deftest.deftest.d.ts +47 -0
- package/generated/dicebag.dicebag.d.ts +90 -0
- package/generated/event.event.d.ts +54 -0
- package/generated/gooey.gooey.d.ts +261 -0
- package/generated/immutable.immutable.d.ts +13 -0
- package/generated/in.accelerometer.d.ts +37 -0
- package/generated/in.button.d.ts +20 -0
- package/generated/in.cursor.d.ts +33 -0
- package/generated/in.gesture.d.ts +64 -0
- package/generated/in.keyboard.d.ts +18 -0
- package/generated/in.mapper.d.ts +23 -0
- package/generated/in.onscreen.d.ts +58 -0
- package/generated/in.state.d.ts +34 -0
- package/generated/in.textbox.d.ts +26 -0
- package/generated/in.triggers.d.ts +180 -0
- package/generated/lang.lang.d.ts +33 -0
- package/generated/log.log.d.ts +40 -0
- package/generated/metrics.fps.d.ts +16 -0
- package/generated/metrics.mem.d.ts +16 -0
- package/generated/monarch.monarch.d.ts +412 -0
- package/generated/monarch.transitions.easings.d.ts +65 -0
- package/generated/monarch.transitions.gui.d.ts +197 -0
- package/generated/nakama.engine.defold.d.ts +24 -0
- package/generated/nakama.nakama.d.ts +594 -0
- package/generated/nakama.util.log.d.ts +10 -0
- package/generated/narrator.narrator.d.ts +66 -0
- package/generated/orthographic.camera.d.ts +308 -0
- package/generated/persist.persist.d.ts +34 -0
- package/generated/platypus.platypus.d.ts +76 -0
- package/generated/proto.proto.d.ts +36 -0
- package/generated/rendy.rendy.d.ts +184 -0
- package/generated/richtext.color.d.ts +33 -0
- package/generated/richtext.richtext.d.ts +126 -0
- package/generated/richtext.tags.d.ts +12 -0
- package/generated/saver.saver.d.ts +44 -0
- package/generated/saver.storage.d.ts +16 -0
- package/generated/squid.squid.d.ts +106 -0
- package/generated/starly.starly.d.ts +148 -0
- package/generated/tweener.tweener.d.ts +151 -0
- package/generated/yagames.yagames.d.ts +279 -0
- package/generated/zzfx.api.d.ts +20 -0
- package/library-classification.json +726 -0
- package/library-targets.json +291 -0
- package/package.json +180 -0
- package/scripts/extract-api-doc.ts +418 -0
- package/scripts/sync-library-types.ts +542 -0
|
@@ -0,0 +1,1585 @@
|
|
|
1
|
+
/** @noSelfInFile **/
|
|
2
|
+
|
|
3
|
+
/** Callback that receives a game object as its argument. */
|
|
4
|
+
declare type BoomObjectCallback = (
|
|
5
|
+
target: BoomBlankGameObject & Partial<BoomComponent>,
|
|
6
|
+
) => void;
|
|
7
|
+
|
|
8
|
+
/** Callback that receives a function that cancels an event listener as its argument. */
|
|
9
|
+
declare type BoomEventCallback = (cancel: BoomCancelEvent) => void;
|
|
10
|
+
|
|
11
|
+
/** Function that cancels an event listener. */
|
|
12
|
+
declare type BoomCancelEvent = () => void;
|
|
13
|
+
|
|
14
|
+
/** Tag representing a component, or any `string` value as a component-less tag. */
|
|
15
|
+
declare type BoomTag = string;
|
|
16
|
+
|
|
17
|
+
/** Keyboard keys. */
|
|
18
|
+
declare type BoomKeyboardKey =
|
|
19
|
+
| 'key_space'
|
|
20
|
+
| 'key_exclamationmark'
|
|
21
|
+
| 'key_doublequote'
|
|
22
|
+
| 'key_hash'
|
|
23
|
+
| 'key_dollarsign'
|
|
24
|
+
| 'key_ampersand'
|
|
25
|
+
| 'key_singlequote'
|
|
26
|
+
| 'key_lparen'
|
|
27
|
+
| 'key_rparen'
|
|
28
|
+
| 'key_asterisk'
|
|
29
|
+
| 'key_plus'
|
|
30
|
+
| 'key_comma'
|
|
31
|
+
| 'key_minus'
|
|
32
|
+
| 'key_period'
|
|
33
|
+
| 'key_slash'
|
|
34
|
+
| 'key_0'
|
|
35
|
+
| 'key_1'
|
|
36
|
+
| 'key_2'
|
|
37
|
+
| 'key_3'
|
|
38
|
+
| 'key_4'
|
|
39
|
+
| 'key_5'
|
|
40
|
+
| 'key_6'
|
|
41
|
+
| 'key_7'
|
|
42
|
+
| 'key_8'
|
|
43
|
+
| 'key_9'
|
|
44
|
+
| 'key_colon'
|
|
45
|
+
| 'key_semicolon'
|
|
46
|
+
| 'key_lessthan'
|
|
47
|
+
| 'key_equals'
|
|
48
|
+
| 'key_greaterthan'
|
|
49
|
+
| 'key_questionmark'
|
|
50
|
+
| 'key_at'
|
|
51
|
+
| 'key_a'
|
|
52
|
+
| 'key_b'
|
|
53
|
+
| 'key_c'
|
|
54
|
+
| 'key_d'
|
|
55
|
+
| 'key_e'
|
|
56
|
+
| 'key_f'
|
|
57
|
+
| 'key_g'
|
|
58
|
+
| 'key_h'
|
|
59
|
+
| 'key_i'
|
|
60
|
+
| 'key_j'
|
|
61
|
+
| 'key_k'
|
|
62
|
+
| 'key_l'
|
|
63
|
+
| 'key_m'
|
|
64
|
+
| 'key_n'
|
|
65
|
+
| 'key_o'
|
|
66
|
+
| 'key_p'
|
|
67
|
+
| 'key_q'
|
|
68
|
+
| 'key_r'
|
|
69
|
+
| 'key_s'
|
|
70
|
+
| 'key_t'
|
|
71
|
+
| 'key_u'
|
|
72
|
+
| 'key_v'
|
|
73
|
+
| 'key_w'
|
|
74
|
+
| 'key_x'
|
|
75
|
+
| 'key_y'
|
|
76
|
+
| 'key_z'
|
|
77
|
+
| 'key_lbracket'
|
|
78
|
+
| 'key_rbracket'
|
|
79
|
+
| 'key_backslash'
|
|
80
|
+
| 'key_caret'
|
|
81
|
+
| 'key_underscore'
|
|
82
|
+
| 'key_grave'
|
|
83
|
+
| 'key_lbrace'
|
|
84
|
+
| 'key_rbrace'
|
|
85
|
+
| 'key_pipe'
|
|
86
|
+
| 'key_esc'
|
|
87
|
+
| 'key_f1'
|
|
88
|
+
| 'key_f2'
|
|
89
|
+
| 'key_f3'
|
|
90
|
+
| 'key_f4'
|
|
91
|
+
| 'key_f5'
|
|
92
|
+
| 'key_f6'
|
|
93
|
+
| 'key_f7'
|
|
94
|
+
| 'key_f8'
|
|
95
|
+
| 'key_f9'
|
|
96
|
+
| 'key_f10'
|
|
97
|
+
| 'key_f11'
|
|
98
|
+
| 'key_f12'
|
|
99
|
+
| 'key_up'
|
|
100
|
+
| 'key_down'
|
|
101
|
+
| 'key_left'
|
|
102
|
+
| 'key_right'
|
|
103
|
+
| 'key_lshift'
|
|
104
|
+
| 'key_rshift'
|
|
105
|
+
| 'key_lctrl'
|
|
106
|
+
| 'key_rctrl'
|
|
107
|
+
| 'key_lalt'
|
|
108
|
+
| 'key_ralt'
|
|
109
|
+
| 'key_tab'
|
|
110
|
+
| 'key_enter'
|
|
111
|
+
| 'key_backspace'
|
|
112
|
+
| 'key_insert'
|
|
113
|
+
| 'key_del'
|
|
114
|
+
| 'key_pageup'
|
|
115
|
+
| 'key_pagedown'
|
|
116
|
+
| 'key_home'
|
|
117
|
+
| 'key_end'
|
|
118
|
+
| 'key_numpad_0'
|
|
119
|
+
| 'key_numpad_1'
|
|
120
|
+
| 'key_numpad_2'
|
|
121
|
+
| 'key_numpad_3'
|
|
122
|
+
| 'key_numpad_4'
|
|
123
|
+
| 'key_numpad_5'
|
|
124
|
+
| 'key_numpad_6'
|
|
125
|
+
| 'key_numpad_7'
|
|
126
|
+
| 'key_numpad_8'
|
|
127
|
+
| 'key_numpad_9'
|
|
128
|
+
| 'key_numpad_divide'
|
|
129
|
+
| 'key_numpad_multiply'
|
|
130
|
+
| 'key_numpad_subtract'
|
|
131
|
+
| 'key_numpad_add'
|
|
132
|
+
| 'key_numpad_decimal'
|
|
133
|
+
| 'key_numpad_equal'
|
|
134
|
+
| 'key_numpad_enter'
|
|
135
|
+
| 'key_numpad_numlock'
|
|
136
|
+
| 'key_capslock'
|
|
137
|
+
| 'key_scrolllock'
|
|
138
|
+
| 'key_pause'
|
|
139
|
+
| 'key_lsuper'
|
|
140
|
+
| 'key_rsuper'
|
|
141
|
+
| 'key_menu'
|
|
142
|
+
| 'key_back'
|
|
143
|
+
| '*';
|
|
144
|
+
|
|
145
|
+
/** Defold Easing types. */
|
|
146
|
+
declare type BoomEasing =
|
|
147
|
+
| typeof go.EASING_INBACK
|
|
148
|
+
| typeof go.EASING_INBOUNCE
|
|
149
|
+
| typeof go.EASING_INCIRC
|
|
150
|
+
| typeof go.EASING_INCUBIC
|
|
151
|
+
| typeof go.EASING_INELASTIC
|
|
152
|
+
| typeof go.EASING_INEXPO
|
|
153
|
+
| typeof go.EASING_INOUTBACK
|
|
154
|
+
| typeof go.EASING_INOUTBOUNCE
|
|
155
|
+
| typeof go.EASING_INOUTCIRC
|
|
156
|
+
| typeof go.EASING_INOUTCUBIC
|
|
157
|
+
| typeof go.EASING_INOUTELASTIC
|
|
158
|
+
| typeof go.EASING_INOUTEXPO
|
|
159
|
+
| typeof go.EASING_INOUTQUAD
|
|
160
|
+
| typeof go.EASING_INOUTQUART
|
|
161
|
+
| typeof go.EASING_INOUTQUINT
|
|
162
|
+
| typeof go.EASING_INOUTSINE
|
|
163
|
+
| typeof go.EASING_INQUAD
|
|
164
|
+
| typeof go.EASING_INQUART
|
|
165
|
+
| typeof go.EASING_INQUINT
|
|
166
|
+
| typeof go.EASING_INSINE
|
|
167
|
+
| typeof go.EASING_LINEAR
|
|
168
|
+
| typeof go.EASING_OUTBACK
|
|
169
|
+
| typeof go.EASING_OUTBOUNCE
|
|
170
|
+
| typeof go.EASING_OUTCIRC
|
|
171
|
+
| typeof go.EASING_OUTCUBIC
|
|
172
|
+
| typeof go.EASING_OUTELASTIC
|
|
173
|
+
| typeof go.EASING_OUTEXPO
|
|
174
|
+
| typeof go.EASING_OUTINBACK
|
|
175
|
+
| typeof go.EASING_OUTINBOUNCE
|
|
176
|
+
| typeof go.EASING_OUTINCIRC
|
|
177
|
+
| typeof go.EASING_OUTINCUBIC
|
|
178
|
+
| typeof go.EASING_OUTINELASTIC
|
|
179
|
+
| typeof go.EASING_OUTINEXPO
|
|
180
|
+
| typeof go.EASING_OUTINQUAD
|
|
181
|
+
| typeof go.EASING_OUTINQUART
|
|
182
|
+
| typeof go.EASING_OUTINQUINT
|
|
183
|
+
| typeof go.EASING_OUTINSINE
|
|
184
|
+
| typeof go.EASING_OUTQUAD
|
|
185
|
+
| typeof go.EASING_OUTQUART
|
|
186
|
+
| typeof go.EASING_OUTQUINT
|
|
187
|
+
| typeof go.EASING_OUTSINE;
|
|
188
|
+
|
|
189
|
+
//
|
|
190
|
+
// Start
|
|
191
|
+
//
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Boom is a game framework built on top of Defold.
|
|
195
|
+
* @see {@link https://github.com/britzl/boom|Github Source}
|
|
196
|
+
* @noResolution
|
|
197
|
+
*/
|
|
198
|
+
declare module 'boom.boom' {
|
|
199
|
+
/**
|
|
200
|
+
* Start a boom game. Call this from your own game script
|
|
201
|
+
* @param game Game loop function
|
|
202
|
+
*/
|
|
203
|
+
export function boom(game: () => void): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//
|
|
207
|
+
// Game object
|
|
208
|
+
//
|
|
209
|
+
|
|
210
|
+
/** A game object that may be composed of components. */
|
|
211
|
+
declare type BoomGameObject<T extends Array<BoomComponent | BoomTag>> =
|
|
212
|
+
UnionToIntersection<
|
|
213
|
+
BoomBlankGameObject & T extends Array<infer U>
|
|
214
|
+
? U extends BoomComponent
|
|
215
|
+
? BoomBlankGameObject &
|
|
216
|
+
ObjectIntersection<T> & { tags: LuaMap<string, true> }
|
|
217
|
+
: BoomBlankGameObject & { readonly tags: LuaMap<string, true> }
|
|
218
|
+
: never
|
|
219
|
+
>;
|
|
220
|
+
|
|
221
|
+
// Extract the properties of an object type
|
|
222
|
+
type ObjectProperties<T> = T extends BoomComponent ? Omit<T, 'tag'> : never;
|
|
223
|
+
|
|
224
|
+
// Extract the union of object types from the input array
|
|
225
|
+
type ObjectUnion<T extends Array<BoomComponent | BoomTag>> = Extract<
|
|
226
|
+
T[number],
|
|
227
|
+
BoomComponent
|
|
228
|
+
>;
|
|
229
|
+
|
|
230
|
+
type ObjectIntersection<T extends Array<BoomComponent | BoomTag>> =
|
|
231
|
+
ObjectProperties<ObjectUnion<T>>;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Create an intersection type from the union of object types.
|
|
235
|
+
* This type is copied from kaboom.
|
|
236
|
+
* @see {@link https://github.com/replit/kaboom|kaboom Source}
|
|
237
|
+
* @license MIT
|
|
238
|
+
* @copyright 2021 Replit
|
|
239
|
+
*/
|
|
240
|
+
// Begin Copied Section
|
|
241
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
242
|
+
k: infer I,
|
|
243
|
+
) => void
|
|
244
|
+
? I
|
|
245
|
+
: never;
|
|
246
|
+
// End Copied Section
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A game object.
|
|
250
|
+
* @noSelf
|
|
251
|
+
*/
|
|
252
|
+
interface BoomBlankGameObject {
|
|
253
|
+
/**
|
|
254
|
+
* Add a game object as a child of this game object
|
|
255
|
+
* by composing it with components.
|
|
256
|
+
* @param comps The game object components
|
|
257
|
+
* @returns The game object
|
|
258
|
+
*/
|
|
259
|
+
add<T extends (BoomComponent | BoomTag)[]>(comps: T): BoomGameObject<T>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Destroy this game object.
|
|
263
|
+
*/
|
|
264
|
+
destroy(): void;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Check if there is a certain tag on this game object.
|
|
268
|
+
* @param tag The tag to check
|
|
269
|
+
* @returns Returns true if the tag exists on the game object
|
|
270
|
+
*/
|
|
271
|
+
is(tag: BoomTag): boolean;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Add a component to this game object, or a component-less tag.
|
|
275
|
+
* @param comp The component or tag to use
|
|
276
|
+
*/
|
|
277
|
+
use(comp: BoomTag | BoomComponent): void;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Remove a component from this game object.
|
|
281
|
+
* @param tag The component tag to remove
|
|
282
|
+
*/
|
|
283
|
+
unuse(tag: BoomTag): void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Get state for a specific component on this game object.
|
|
287
|
+
* @param tag The component to get state for
|
|
288
|
+
* @returns The component state
|
|
289
|
+
*/
|
|
290
|
+
c(tag: BoomTag): BoomBlankGameObject &
|
|
291
|
+
Partial<BoomComponent> & {
|
|
292
|
+
readonly tag: BoomTag;
|
|
293
|
+
readonly __url?: Url;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
readonly dirty: boolean;
|
|
297
|
+
readonly children: LuaMap;
|
|
298
|
+
readonly comps: LuaMap<string | number, LuaMap<string, unknown>>;
|
|
299
|
+
readonly properties: LuaMap<string, unknown>;
|
|
300
|
+
readonly id: Hash;
|
|
301
|
+
readonly ids: LuaMap<Hash, Hash>;
|
|
302
|
+
readonly tags: LuaMap<string | Hash, boolean>;
|
|
303
|
+
readonly pre_update?: LuaSet<Function>;
|
|
304
|
+
readonly update?: LuaSet<Function>;
|
|
305
|
+
readonly post_update?: LuaSet<Function>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Add a game object with a set of components.
|
|
310
|
+
* @param comps The components for the game object
|
|
311
|
+
* @returns The created game object
|
|
312
|
+
*/
|
|
313
|
+
declare function add<T extends (BoomComponent | BoomTag)[]>(
|
|
314
|
+
comps: T,
|
|
315
|
+
): BoomGameObject<T>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Destroy a game object and all of its components.
|
|
319
|
+
* @param object The object to destroy
|
|
320
|
+
*/
|
|
321
|
+
declare function destroy(
|
|
322
|
+
object: BoomBlankGameObject & Partial<BoomComponent>,
|
|
323
|
+
): void;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Destroy all game objects with a certain tag.
|
|
327
|
+
* @param tag The tag to destroy or undefined to destroy all objects
|
|
328
|
+
*/
|
|
329
|
+
declare function destroy_all(tag?: BoomTag): void;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Get game object with specific id.
|
|
333
|
+
* @param id
|
|
334
|
+
* @returns The object or undefined if it doesn't exist
|
|
335
|
+
*/
|
|
336
|
+
declare function object(
|
|
337
|
+
id: string,
|
|
338
|
+
): (BoomBlankGameObject & Partial<BoomComponent>) | undefined;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Get all game objects.
|
|
342
|
+
* @returns All game objects
|
|
343
|
+
*/
|
|
344
|
+
declare function objects(): LuaSet<
|
|
345
|
+
BoomBlankGameObject & Partial<BoomComponent>
|
|
346
|
+
>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get all game objects with the specified tag.
|
|
350
|
+
* @param tag The tag to get objects for, undefined to get all objects
|
|
351
|
+
* @returns List of objects
|
|
352
|
+
*/
|
|
353
|
+
declare function get(
|
|
354
|
+
tag?: BoomTag,
|
|
355
|
+
): LuaSet<BoomBlankGameObject & Partial<BoomComponent>>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Run callback on every game object with a certain tag.
|
|
359
|
+
* @param tag The tag that must exist on the object
|
|
360
|
+
* @param cb The callback to run
|
|
361
|
+
*/
|
|
362
|
+
declare function every(tag: BoomTag, cb: BoomObjectCallback): void;
|
|
363
|
+
|
|
364
|
+
//
|
|
365
|
+
// Components
|
|
366
|
+
//
|
|
367
|
+
|
|
368
|
+
/** A set of components and/or arbitrary `string`s used as component-less tags. */
|
|
369
|
+
declare type BoomComponentOrTagSet =
|
|
370
|
+
| Array<BoomComponent | BoomTag>
|
|
371
|
+
| LuaSet<BoomComponent | BoomTag>;
|
|
372
|
+
|
|
373
|
+
/** One of 20 built-in components. */
|
|
374
|
+
declare type BoomComponent =
|
|
375
|
+
| AnchorComp
|
|
376
|
+
| AreaComp
|
|
377
|
+
| BodyComp
|
|
378
|
+
| ColorComp
|
|
379
|
+
| DoubleJumpComp
|
|
380
|
+
| FadeInComp
|
|
381
|
+
| FixedComp
|
|
382
|
+
| HealthComp
|
|
383
|
+
| LifespanComp
|
|
384
|
+
| MoveComp
|
|
385
|
+
| OffscreenComp
|
|
386
|
+
| OpacityComp
|
|
387
|
+
| PosComp
|
|
388
|
+
| RotateComp
|
|
389
|
+
| ScaleComp
|
|
390
|
+
| SpriteComp
|
|
391
|
+
| StayComp
|
|
392
|
+
| TextComp
|
|
393
|
+
| TimerComp
|
|
394
|
+
| ZComp;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Anchor component. Use this component to offset any rendered component
|
|
398
|
+
* such as a `SpriteComp` from the center of the game object.
|
|
399
|
+
* @noSelf
|
|
400
|
+
*/
|
|
401
|
+
interface AnchorComp {
|
|
402
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
403
|
+
readonly tag: 'anchor';
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Anchor point.
|
|
407
|
+
*/
|
|
408
|
+
anchor: Vec2;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Area component. Use this component to define a collider area and bounds for a game object.
|
|
413
|
+
* The area can be either a rectangle or a circle. The size can either be set manually or
|
|
414
|
+
* based on the size of a renderable component, such as a sprite.
|
|
415
|
+
* @noSelf
|
|
416
|
+
*/
|
|
417
|
+
interface AreaComp {
|
|
418
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
419
|
+
readonly tag: 'area';
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Get all collisions currently happening for this component.
|
|
423
|
+
* @returns Set of collisions
|
|
424
|
+
*/
|
|
425
|
+
get_collisions(): LuaSet<BoomCollision>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Check collision between this component and another object.
|
|
429
|
+
* @param other_object The game object to check collisions with.
|
|
430
|
+
* @returns boolean (`true` if colliding with the other object), Collision data
|
|
431
|
+
*/
|
|
432
|
+
check_collision(
|
|
433
|
+
other_object: BoomBlankGameObject & Partial<BoomComponent>,
|
|
434
|
+
): LuaMultiReturn<[boolean, BoomCollision]>;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Register event listener when this component is colliding.
|
|
438
|
+
* @param tag Optional tag which colliding object must have, undefined for all collisions
|
|
439
|
+
* @param cb Function to call when collision is detected
|
|
440
|
+
*/
|
|
441
|
+
on_collide(tag: BoomTag | undefined, cb: (data: BoomCollision) => void): void;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Register event listener when this component is clicked.
|
|
445
|
+
* @param cb Function to call when clicked
|
|
446
|
+
*/
|
|
447
|
+
on_click(cb: BoomObjectCallback): void;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Check if a point is within the area of this component.
|
|
451
|
+
* @param point The point to check
|
|
452
|
+
* @returns `true` if point is within area
|
|
453
|
+
*/
|
|
454
|
+
has_point(point: undefined): boolean;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Url of the collision object used by the area.
|
|
458
|
+
* Undefined on the first frame that the object is created.
|
|
459
|
+
*/
|
|
460
|
+
readonly area_url: Url | undefined;
|
|
461
|
+
|
|
462
|
+
readonly init?: () => void;
|
|
463
|
+
readonly pre_update?: () => void;
|
|
464
|
+
readonly update?: (dt: number) => void;
|
|
465
|
+
readonly destroy?: () => void;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Physical body that responds to gravity.
|
|
470
|
+
* Requires `AreaComp` and `PosComp` components on the game object.
|
|
471
|
+
* This also makes the object solid.
|
|
472
|
+
* @noSelf
|
|
473
|
+
*/
|
|
474
|
+
interface BodyComp {
|
|
475
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
476
|
+
readonly tag: 'body';
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Add upward force.
|
|
480
|
+
* @param force The upward force to apply
|
|
481
|
+
*/
|
|
482
|
+
jump(force: number): void;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* If the body is jumping (velocity is pointing up).
|
|
486
|
+
*/
|
|
487
|
+
readonly is_jumping: boolean;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* If the body is in contact with ground.
|
|
491
|
+
*/
|
|
492
|
+
readonly is_grounded: boolean;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* If the body is falling (velocity is pointing down).
|
|
496
|
+
*/
|
|
497
|
+
readonly is_falling: boolean;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* The upward velocity applied to the body when jumping.
|
|
501
|
+
*/
|
|
502
|
+
readonly jump_force: number; // TO-DO should this be mutable?
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* If the body is static and not affected by gravity.
|
|
506
|
+
*/
|
|
507
|
+
readonly is_static: boolean; // TO-DO should this be mutable?
|
|
508
|
+
|
|
509
|
+
readonly update?: (dt: number) => void;
|
|
510
|
+
readonly destroy?: () => void;
|
|
511
|
+
readonly init?: () => void;
|
|
512
|
+
readonly pre_update?: () => void;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Component to control the color of the game object.
|
|
517
|
+
* @noSelf
|
|
518
|
+
*/
|
|
519
|
+
interface ColorComp {
|
|
520
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
521
|
+
readonly tag: 'color';
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Current color.
|
|
525
|
+
*/
|
|
526
|
+
readonly color: {
|
|
527
|
+
/**
|
|
528
|
+
* Darkens the color.
|
|
529
|
+
* @param n Amount to darken color by
|
|
530
|
+
*/
|
|
531
|
+
readonly darken: (n: number) => ColorComp;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Invert the color.
|
|
535
|
+
*/
|
|
536
|
+
readonly invert: () => ColorComp;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Clone the color.
|
|
540
|
+
*/
|
|
541
|
+
readonly clone: () => ColorComp;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Lighten the color.
|
|
545
|
+
* @param n Amount to lighten color by
|
|
546
|
+
*/
|
|
547
|
+
readonly lighten: (n: number) => ColorComp;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* The red color component. (0.0 to 1.0).
|
|
551
|
+
*/
|
|
552
|
+
r: number;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* The green color component. (0.0 to 1.0).
|
|
556
|
+
*/
|
|
557
|
+
g: number;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* The blue color component. (0.0 to 1.0).
|
|
561
|
+
*/
|
|
562
|
+
b: number;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* The alpha (tranparency) of the color. (0.0 to 1.0).
|
|
566
|
+
*/
|
|
567
|
+
a: number;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Enables double jump. Requires `BodyComp` component.
|
|
573
|
+
* @noSelf
|
|
574
|
+
*/
|
|
575
|
+
interface DoubleJumpComp {
|
|
576
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
577
|
+
readonly tag: 'double_jump';
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Performs double jump (the initial jump only happens if player is grounded).
|
|
581
|
+
* @param force The upward force to apply
|
|
582
|
+
*/
|
|
583
|
+
double_jump(force: number): void;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Maximum number of jumps.
|
|
587
|
+
*/
|
|
588
|
+
readonly num_jumps: number; // TO-DO should this be mutable?
|
|
589
|
+
|
|
590
|
+
readonly init?: () => void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Fade in game object visual components such as sprites.
|
|
595
|
+
* @noSelf
|
|
596
|
+
*/
|
|
597
|
+
interface FadeInComp {
|
|
598
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
599
|
+
readonly tag: 'fadein';
|
|
600
|
+
|
|
601
|
+
readonly init?: () => void;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Make object unaffected by camera.
|
|
606
|
+
* @noSelf
|
|
607
|
+
*/
|
|
608
|
+
interface FixedComp {
|
|
609
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
610
|
+
readonly tag: 'fixed';
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Handles health related logic.
|
|
615
|
+
* @noSelf
|
|
616
|
+
*/
|
|
617
|
+
interface HealthComp {
|
|
618
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
619
|
+
readonly tag: 'health';
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Register an event that runs when `heal()` is called.
|
|
623
|
+
* @param cb Function to call
|
|
624
|
+
*/
|
|
625
|
+
on_heal(cb: (cancel: BoomCancelEvent) => void): void;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Register an event that runs when `hurt()` is called.
|
|
629
|
+
* @param cb Function to call
|
|
630
|
+
*/
|
|
631
|
+
on_hurt(cb: (cancel: BoomCancelEvent) => void): void;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Register an event that runs when hp is 0 or less.
|
|
635
|
+
* @param cb Function to call
|
|
636
|
+
*/
|
|
637
|
+
on_death(cb: (cancel: BoomCancelEvent) => void): void;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Increase hp. Will trigger `on_heal`.
|
|
641
|
+
* @param n Amount to increase
|
|
642
|
+
*/
|
|
643
|
+
heal(n: number): void;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Decrease hp. Will trigger `on_hurt`.
|
|
647
|
+
* @param n Amount to decrease
|
|
648
|
+
*/
|
|
649
|
+
hurt(n: number): void;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Current hp.
|
|
653
|
+
*/
|
|
654
|
+
hp: number;
|
|
655
|
+
|
|
656
|
+
readonly destroy?: () => void;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Destroy the game object after certain amount of time.
|
|
661
|
+
* Use this component when you need a game object to be destroyed after a period of time.
|
|
662
|
+
* @noSelf
|
|
663
|
+
*/
|
|
664
|
+
interface LifespanComp {
|
|
665
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
666
|
+
readonly tag: 'lifespan';
|
|
667
|
+
|
|
668
|
+
readonly init?: () => void;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Component to move a game object in a direction of travel and at a specific speed.
|
|
673
|
+
* @noSelf
|
|
674
|
+
*/
|
|
675
|
+
interface MoveComp {
|
|
676
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
677
|
+
readonly tag: 'move';
|
|
678
|
+
|
|
679
|
+
direction: Vec2;
|
|
680
|
+
speed: number;
|
|
681
|
+
|
|
682
|
+
readonly init?: () => void;
|
|
683
|
+
readonly update?: (dt: number) => void;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Control the behavior of a game object when it goes out of view.
|
|
688
|
+
* @noSelf
|
|
689
|
+
*/
|
|
690
|
+
interface OffscreenComp {
|
|
691
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
692
|
+
readonly tag: 'offscreen';
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Register a callback that runs when the object goes out of view.
|
|
696
|
+
* @param cb Function to call when the object goes out of view
|
|
697
|
+
*/
|
|
698
|
+
on_exit_screen(cb: () => void): void;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Register a callback that runs when the object enters view.
|
|
702
|
+
* @param cb Function to call when the object enters view
|
|
703
|
+
*/
|
|
704
|
+
on_enter_screen(cb: () => void): void;
|
|
705
|
+
|
|
706
|
+
readonly is_offscreen: boolean;
|
|
707
|
+
readonly update?: (dt: number) => void;
|
|
708
|
+
readonly init?: () => void;
|
|
709
|
+
readonly destroy?: () => void;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Component to control the opacity of a game object.
|
|
714
|
+
* @noSelf
|
|
715
|
+
*/
|
|
716
|
+
interface OpacityComp {
|
|
717
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
718
|
+
readonly tag: 'opacity';
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* The opacity of the component instance. (0.0 to 1.0).
|
|
722
|
+
*/
|
|
723
|
+
opacity: number;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Position of a game object.
|
|
728
|
+
* @noSelf
|
|
729
|
+
*/
|
|
730
|
+
interface PosComp {
|
|
731
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
732
|
+
readonly tag: 'pos';
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Move a number of pixels per second.
|
|
736
|
+
* @param x
|
|
737
|
+
* @param y
|
|
738
|
+
*/
|
|
739
|
+
move(x: number, y: number): void;
|
|
740
|
+
|
|
741
|
+
/** Position in 2D space. */
|
|
742
|
+
pos: Vec2;
|
|
743
|
+
|
|
744
|
+
/** Velocity. */
|
|
745
|
+
vel: Vec2;
|
|
746
|
+
|
|
747
|
+
readonly update?: (dt: number) => void;
|
|
748
|
+
readonly init?: () => void;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Apply rotation to object.
|
|
753
|
+
* @noSelf
|
|
754
|
+
*/
|
|
755
|
+
interface RotateComp {
|
|
756
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
757
|
+
readonly tag: 'rotate';
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Updates rotation.
|
|
761
|
+
* @param angle in degrees
|
|
762
|
+
*/
|
|
763
|
+
rotate: (angle: number) => void;
|
|
764
|
+
|
|
765
|
+
readonly angle: number;
|
|
766
|
+
readonly init?: () => void;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Apply a scale to the object.
|
|
771
|
+
* @noSelf
|
|
772
|
+
*/
|
|
773
|
+
interface ScaleComp {
|
|
774
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
775
|
+
readonly tag: 'scale';
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Set new scale.
|
|
779
|
+
* @param x
|
|
780
|
+
* @param y defaults to x
|
|
781
|
+
*/
|
|
782
|
+
scale_to: (x: number, y?: number) => void;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Change scale.
|
|
786
|
+
* @param x
|
|
787
|
+
* @param y defaults to x
|
|
788
|
+
*/
|
|
789
|
+
scale_by: (x: number, y?: number) => void;
|
|
790
|
+
|
|
791
|
+
readonly scale: Vec2;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Render a sprite.
|
|
796
|
+
* @noSelf
|
|
797
|
+
*/
|
|
798
|
+
interface SpriteComp {
|
|
799
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
800
|
+
readonly tag: 'sprite';
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Play an animation.
|
|
804
|
+
* @param anim The animation to play
|
|
805
|
+
*/
|
|
806
|
+
play(anim: string): void;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Stop the current animation.
|
|
810
|
+
*/
|
|
811
|
+
stop(): void;
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* The current animation.
|
|
815
|
+
*/
|
|
816
|
+
readonly anim: string;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* The width of the sprite.
|
|
820
|
+
*/
|
|
821
|
+
readonly width: number;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* The height of the sprite.
|
|
825
|
+
*/
|
|
826
|
+
readonly height: number;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* If sprite should be flipped horizontally.
|
|
830
|
+
*/
|
|
831
|
+
flip_x: boolean;
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* If the sprite should be flipped vertically.
|
|
835
|
+
*/
|
|
836
|
+
flip_y: boolean;
|
|
837
|
+
|
|
838
|
+
readonly init?: () => void;
|
|
839
|
+
readonly pre_update?: (dt: number) => void;
|
|
840
|
+
readonly destroy?: () => void;
|
|
841
|
+
readonly update?: (dt: number) => void;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Do not get destroyed on scene switch.
|
|
846
|
+
* @noSelf
|
|
847
|
+
*/
|
|
848
|
+
interface StayComp {
|
|
849
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
850
|
+
readonly tag: 'stay';
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Render text.
|
|
855
|
+
* @noSelf
|
|
856
|
+
*/
|
|
857
|
+
interface TextComp {
|
|
858
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
859
|
+
readonly tag: 'text';
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* The text to render.
|
|
863
|
+
*/
|
|
864
|
+
text: string;
|
|
865
|
+
|
|
866
|
+
readonly init?: () => void;
|
|
867
|
+
readonly destroy?: () => void;
|
|
868
|
+
readonly update?: (dt: number) => void;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Run an action once or repeatedly at a set interval.
|
|
873
|
+
* @noSelf
|
|
874
|
+
*/
|
|
875
|
+
interface TimerComp {
|
|
876
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
877
|
+
readonly tag: 'timer';
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Run a callback function after n seconds.
|
|
881
|
+
* @param n Seconds
|
|
882
|
+
* @param fn The function to call
|
|
883
|
+
*/
|
|
884
|
+
wait(n: number, fn: () => void): void;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Run a callback function every n seconds.
|
|
888
|
+
* @param n Seconds
|
|
889
|
+
* @param fn The function to call
|
|
890
|
+
*/
|
|
891
|
+
loop(n: number, fn: () => void): void;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Cancel the timer.
|
|
895
|
+
*/
|
|
896
|
+
cancel(): void;
|
|
897
|
+
|
|
898
|
+
readonly destroy?: () => void;
|
|
899
|
+
readonly init?: () => void;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Determines the draw order for objects.
|
|
904
|
+
* Object will be drawn on top if z value is bigger.
|
|
905
|
+
* @noSelf
|
|
906
|
+
*/
|
|
907
|
+
interface ZComp {
|
|
908
|
+
/** Pushed into the `tags` map when added to a game object. */
|
|
909
|
+
readonly tag: 'z';
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* The z value.
|
|
913
|
+
*/
|
|
914
|
+
z: number;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Anchor point for render.
|
|
919
|
+
* @param anchor
|
|
920
|
+
* @returns The anchor component
|
|
921
|
+
*/
|
|
922
|
+
declare function anchor(
|
|
923
|
+
anchor:
|
|
924
|
+
| 'center'
|
|
925
|
+
| 'topleft'
|
|
926
|
+
| 'top'
|
|
927
|
+
| 'topright'
|
|
928
|
+
| 'left'
|
|
929
|
+
| 'right'
|
|
930
|
+
| 'bottomright'
|
|
931
|
+
| 'bottom'
|
|
932
|
+
| 'bottomleft',
|
|
933
|
+
): AnchorComp;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Create a collider area and enable collision detection.
|
|
937
|
+
* This will create an area component which is used to describe an area
|
|
938
|
+
* which can collide with other area components.
|
|
939
|
+
* @param options Component options (shape, width, height, radius)
|
|
940
|
+
* @returns The area component
|
|
941
|
+
*/
|
|
942
|
+
declare function area(options?: {
|
|
943
|
+
width?: number;
|
|
944
|
+
height?: number;
|
|
945
|
+
radius?: number;
|
|
946
|
+
shape?: 'auto' | 'rect' | 'circle' | 'auto-circle';
|
|
947
|
+
}): AreaComp;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Physical body that responds to gravity. Requires `AreaComp`
|
|
951
|
+
* and `PosComp` components on the game object. This also makes the object solid.
|
|
952
|
+
* @param options Component options (jump_force, is_static)
|
|
953
|
+
* @returns The body component
|
|
954
|
+
*/
|
|
955
|
+
declare function body(options?: {
|
|
956
|
+
jump_force?: number;
|
|
957
|
+
is_static?: boolean;
|
|
958
|
+
}): BodyComp;
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Control the color of the game object.
|
|
962
|
+
* @param r Red (0.0 to 1.0)
|
|
963
|
+
* @param g Green (0.0 to 1.0)
|
|
964
|
+
* @param b Blue (0.0 to 1.0)
|
|
965
|
+
* @param a Optional alpha (0.0 to 1.0)
|
|
966
|
+
* @returns The color component
|
|
967
|
+
*/
|
|
968
|
+
declare function color(
|
|
969
|
+
r?: number,
|
|
970
|
+
g?: number,
|
|
971
|
+
b?: number,
|
|
972
|
+
a?: number,
|
|
973
|
+
): ColorComp;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Enables double jump. Requires body component.
|
|
977
|
+
* @param options Component options
|
|
978
|
+
* @returns The double jump component
|
|
979
|
+
*/
|
|
980
|
+
declare function double_jump(options?: { num_jumps?: number }): DoubleJumpComp;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Fade in game object visual components such as sprites.
|
|
984
|
+
* @param time In seconds (default is 1)
|
|
985
|
+
* @returns The fade in component
|
|
986
|
+
*/
|
|
987
|
+
declare function fadein(time?: number): FadeInComp;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Make object unaffected by camera.
|
|
991
|
+
* @returns The component
|
|
992
|
+
*/
|
|
993
|
+
declare function fixed(): FixedComp;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Add health related logic to game object.
|
|
997
|
+
* @param hp Initial health (default is 1)
|
|
998
|
+
* @returns The health component
|
|
999
|
+
*/
|
|
1000
|
+
declare function health(hp?: number): HealthComp;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Destroy the game object after certain amount of time.
|
|
1004
|
+
* @param time In seconds
|
|
1005
|
+
* @param options Fade out duration (default 0 which is no fade out)
|
|
1006
|
+
*/
|
|
1007
|
+
declare function lifespan(
|
|
1008
|
+
time: number,
|
|
1009
|
+
options?: { fade?: number },
|
|
1010
|
+
): LifespanComp;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Move a game object in a direction of travel and at a specific speed.
|
|
1014
|
+
* @param direction Direction of movement
|
|
1015
|
+
* @param speed Speed of movement in pixels per second
|
|
1016
|
+
* @returns The created component
|
|
1017
|
+
*/
|
|
1018
|
+
declare function move(direction: Vec2, speed: number): MoveComp;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* Control the behavior of a game object when it goes out of view.
|
|
1022
|
+
* @param options Destroy when going offscreen
|
|
1023
|
+
* @returns The created component
|
|
1024
|
+
*/
|
|
1025
|
+
declare function offscreen(options?: {
|
|
1026
|
+
distance?: number;
|
|
1027
|
+
destroy?: boolean;
|
|
1028
|
+
}): OffscreenComp;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Control the opacity of a game object.
|
|
1032
|
+
* @param value The opacity from 0.0 to 1.0
|
|
1033
|
+
* @returns The created component
|
|
1034
|
+
*/
|
|
1035
|
+
declare function opacity(value: number): OpacityComp;
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Control the position of a game object.
|
|
1039
|
+
* @param x
|
|
1040
|
+
* @param y
|
|
1041
|
+
* @returns The created component
|
|
1042
|
+
*/
|
|
1043
|
+
declare function pos(x: number, y: number): PosComp;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Apply rotation to the object.
|
|
1047
|
+
* @param angle
|
|
1048
|
+
* @returns The component
|
|
1049
|
+
*/
|
|
1050
|
+
declare function rotate(angle: number): RotateComp;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Apply a scale to the object.
|
|
1054
|
+
* @param x defaults to 1
|
|
1055
|
+
* @param y defaults to x
|
|
1056
|
+
* @returns The component
|
|
1057
|
+
*/
|
|
1058
|
+
declare function scale(x: number, y?: number): ScaleComp;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Render a sprite.
|
|
1062
|
+
* @param anim Animation or image to use
|
|
1063
|
+
* @param options Extra options (flip_x, flip_y, width, height)
|
|
1064
|
+
*/
|
|
1065
|
+
declare function sprite(
|
|
1066
|
+
anim: string,
|
|
1067
|
+
options?: {
|
|
1068
|
+
atlas?: string | Hash;
|
|
1069
|
+
flip_x?: boolean;
|
|
1070
|
+
flip_y?: boolean;
|
|
1071
|
+
width?: number;
|
|
1072
|
+
height?: number;
|
|
1073
|
+
},
|
|
1074
|
+
): SpriteComp;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Do not get destroyed on scene switch.
|
|
1078
|
+
* @returns The created component
|
|
1079
|
+
*/
|
|
1080
|
+
declare function stay(): StayComp;
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Render text.
|
|
1084
|
+
* @param content The text to show
|
|
1085
|
+
* @param options Text options (width, font, align)
|
|
1086
|
+
* @returns The created component
|
|
1087
|
+
*/
|
|
1088
|
+
declare function text(
|
|
1089
|
+
text: string,
|
|
1090
|
+
options?: {
|
|
1091
|
+
font?: string;
|
|
1092
|
+
align?: 'left' | 'right' | 'center';
|
|
1093
|
+
width?: number;
|
|
1094
|
+
},
|
|
1095
|
+
): TextComp;
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Run certain action after some time.
|
|
1099
|
+
* @param n Number of seconds to wait
|
|
1100
|
+
* @param fn The function to call
|
|
1101
|
+
* @returns The created component
|
|
1102
|
+
*/
|
|
1103
|
+
declare function timer(n: number, fn: () => void): TimerComp;
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Determines the draw order for objects.
|
|
1107
|
+
* Object will be drawn on top if z value is bigger.
|
|
1108
|
+
* @param index Z-value of the object
|
|
1109
|
+
* @returns The created component
|
|
1110
|
+
*/
|
|
1111
|
+
declare function z(index: number): ZComp;
|
|
1112
|
+
|
|
1113
|
+
//
|
|
1114
|
+
// Events
|
|
1115
|
+
//
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Collision event that occurs when two game objects with Area components collide.
|
|
1119
|
+
* @noSelf
|
|
1120
|
+
*/
|
|
1121
|
+
interface BoomCollision {
|
|
1122
|
+
normal: Vector3;
|
|
1123
|
+
distance: number;
|
|
1124
|
+
source: BoomBlankGameObject & Omit<AreaComp, 'tag'> & Partial<BoomComponent>;
|
|
1125
|
+
target: BoomBlankGameObject & Omit<AreaComp, 'tag'> & Partial<BoomComponent>;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Register an event that runs when two game objects collide.
|
|
1130
|
+
* @param tag1 Tag which the first game object must have
|
|
1131
|
+
* @param tag2 Optional tag which the second game object must have
|
|
1132
|
+
* @param fn Will receive (collision, cancel) as args
|
|
1133
|
+
* @returns Cancel event function
|
|
1134
|
+
*/
|
|
1135
|
+
declare function on_collide(
|
|
1136
|
+
tag1: BoomTag,
|
|
1137
|
+
tag2: BoomTag | undefined,
|
|
1138
|
+
fn: (collision: BoomCollision, cancel: BoomCancelEvent) => void,
|
|
1139
|
+
): BoomCancelEvent;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Register callback that runs when a certain key is pressed.
|
|
1143
|
+
* @param key_id The key that must be pressed or '*' for any key
|
|
1144
|
+
* @param cb The callback
|
|
1145
|
+
* @returns Cancel callback
|
|
1146
|
+
*/
|
|
1147
|
+
declare function on_key_press(
|
|
1148
|
+
key_id: BoomKeyboardKey,
|
|
1149
|
+
cb: BoomEventCallback,
|
|
1150
|
+
): BoomCancelEvent;
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Register callback that runs when a certain key is released.
|
|
1154
|
+
* @param key_id The key that must be released or '*' for any key
|
|
1155
|
+
* @param cb The callback
|
|
1156
|
+
* @returns Cancel callback
|
|
1157
|
+
*/
|
|
1158
|
+
declare function on_key_release(
|
|
1159
|
+
key_id: BoomKeyboardKey,
|
|
1160
|
+
cb: BoomEventCallback,
|
|
1161
|
+
): BoomCancelEvent;
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Set mouse click listener.
|
|
1165
|
+
* @param tag Optional click on object with tag filter
|
|
1166
|
+
* @param cb Callback when mouse button is clicked
|
|
1167
|
+
* @returns Cancel listener function
|
|
1168
|
+
*/
|
|
1169
|
+
declare function on_click(
|
|
1170
|
+
tag: BoomTag,
|
|
1171
|
+
cb: BoomObjectCallback,
|
|
1172
|
+
): BoomCancelEvent;
|
|
1173
|
+
declare function on_click(cb: BoomObjectCallback): BoomCancelEvent;
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Register callback that runs when a mouse button is pressed.
|
|
1177
|
+
* @param button Optional (`left`, `middle`, `right`, default is `left`)
|
|
1178
|
+
* @param cb
|
|
1179
|
+
* @returns Cancel callback
|
|
1180
|
+
*/
|
|
1181
|
+
declare function on_mouse_press(
|
|
1182
|
+
button: 'left' | 'middle' | 'right',
|
|
1183
|
+
cb: () => void,
|
|
1184
|
+
): BoomCancelEvent;
|
|
1185
|
+
declare function on_mouse_press(cb: () => void): BoomCancelEvent;
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Register callback that runs when a mouse button is released.
|
|
1189
|
+
* @param button Optional (`left`, `middle`, `right`, default is `left`)
|
|
1190
|
+
* @param cb
|
|
1191
|
+
* @returns Cancel callback
|
|
1192
|
+
*/
|
|
1193
|
+
declare function on_mouse_release(
|
|
1194
|
+
button: 'left' | 'middle' | 'right',
|
|
1195
|
+
cb: () => void,
|
|
1196
|
+
): BoomCancelEvent;
|
|
1197
|
+
declare function on_mouse_release(cb: () => void): BoomCancelEvent;
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Register callback that runs when the mouse is moved.
|
|
1201
|
+
* @param cb
|
|
1202
|
+
* @returns Cancel callback
|
|
1203
|
+
*/
|
|
1204
|
+
declare function on_mouse_move(cb: () => void): BoomCancelEvent;
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Run a function every frame. Register an event that runs every frame,
|
|
1208
|
+
* optionally for all game objects with certain tag.
|
|
1209
|
+
* @param tag Run event for all objects matching tag (optional)
|
|
1210
|
+
* @param fn The event function to call. Will receive object and cancel function.
|
|
1211
|
+
*/
|
|
1212
|
+
declare function on_update(
|
|
1213
|
+
tag: BoomTag,
|
|
1214
|
+
fn: (
|
|
1215
|
+
object: BoomBlankGameObject & Partial<BoomComponent>,
|
|
1216
|
+
cancel: BoomCancelEvent,
|
|
1217
|
+
) => void,
|
|
1218
|
+
): void;
|
|
1219
|
+
declare function on_update(fn: (cancel: BoomCancelEvent) => void): void;
|
|
1220
|
+
|
|
1221
|
+
//
|
|
1222
|
+
// Level
|
|
1223
|
+
//
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Map that describes functionality of tiles.
|
|
1227
|
+
* Keys are `string`s that match tiles.
|
|
1228
|
+
* Values are `function`s that return sets of components.
|
|
1229
|
+
*/
|
|
1230
|
+
declare type BoomTiles =
|
|
1231
|
+
| {
|
|
1232
|
+
[key: string]: () => BoomComponentOrTagSet;
|
|
1233
|
+
}
|
|
1234
|
+
| LuaMap<string, () => BoomComponentOrTagSet>;
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Construct a level based on symbols.
|
|
1238
|
+
* @param map List of strings presenting horizontal rows of tiles
|
|
1239
|
+
* @param options Level options (tile_width, tile_height, pos, tiles)
|
|
1240
|
+
* @returns Game object with tiles as children
|
|
1241
|
+
*/
|
|
1242
|
+
declare function add_level(
|
|
1243
|
+
map: string[] | LuaSet<string>,
|
|
1244
|
+
options: {
|
|
1245
|
+
tile_width: number;
|
|
1246
|
+
tile_height: number;
|
|
1247
|
+
pos?: Vec2;
|
|
1248
|
+
tiles: BoomTiles;
|
|
1249
|
+
},
|
|
1250
|
+
): BoomBlankGameObject & Partial<BoomComponent>;
|
|
1251
|
+
|
|
1252
|
+
//
|
|
1253
|
+
// Math
|
|
1254
|
+
//
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* 2D vector.
|
|
1258
|
+
*/
|
|
1259
|
+
declare type Vec2 = {
|
|
1260
|
+
x: number;
|
|
1261
|
+
y: number;
|
|
1262
|
+
readonly z: 0;
|
|
1263
|
+
readonly __type: Vector3;
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Get distance between this and another vector.
|
|
1267
|
+
*/
|
|
1268
|
+
dist: (compare: Vec2) => number;
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Get a random number. If called with no arguments the function returns a number between 0 and 1.
|
|
1273
|
+
* If called with a single argument `a` a number between 0 and `a` is returned.
|
|
1274
|
+
* If called with two arguments `a` and `b` a number between `a` and `b` is returned.
|
|
1275
|
+
* @param a
|
|
1276
|
+
* @param b
|
|
1277
|
+
* @returns Float number
|
|
1278
|
+
*/
|
|
1279
|
+
declare function rand(a?: number, b?: number): number;
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* Same as `rand()` but floored.
|
|
1283
|
+
* If called with two arguments `a` and `b` a number between `a` and `b` is returned.
|
|
1284
|
+
* @param a
|
|
1285
|
+
* @param b
|
|
1286
|
+
* @returns Integer number
|
|
1287
|
+
*/
|
|
1288
|
+
declare function randi(a?: number, b?: number): number;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Create a color.
|
|
1292
|
+
* @param r Red component (0.0 to 1.0)
|
|
1293
|
+
* @param g Green component (0.0 to 1.0)
|
|
1294
|
+
* @param b Blue component (0.0 to 1.0)
|
|
1295
|
+
* @param a Alpha component (0.0 to 1.0)
|
|
1296
|
+
* @returns The created color
|
|
1297
|
+
*/
|
|
1298
|
+
declare function rgb(r?: number, g?: number, b?: number, a?: number): ColorComp;
|
|
1299
|
+
|
|
1300
|
+
declare namespace rgb {
|
|
1301
|
+
/**
|
|
1302
|
+
* Red color. rgb(1, 0, 0, 1)
|
|
1303
|
+
*/
|
|
1304
|
+
export const RED: ColorComp;
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* Green color. rgb(0, 1, 0, 1)
|
|
1308
|
+
*/
|
|
1309
|
+
export const GREEN: ColorComp;
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Blue color. rgb(0, 0, 1, 1)
|
|
1313
|
+
*/
|
|
1314
|
+
export const BLUE: ColorComp;
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Black color. rgb(0, 0, 0, 1)
|
|
1318
|
+
*/
|
|
1319
|
+
export const BLACK: ColorComp;
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* White color. rgb(1, 1, 1, 1)
|
|
1323
|
+
*/
|
|
1324
|
+
export const WHITE: ColorComp;
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Create color from a hex string.
|
|
1328
|
+
* @param hex Hex string in RGB, RGBA, RRGGBB or RRGGBBAA format (with optional initial #).
|
|
1329
|
+
* @returns The created color.
|
|
1330
|
+
*/
|
|
1331
|
+
export function from_hex(hex: string): ColorComp;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Red color. rgb(1, 0, 0, 1)
|
|
1336
|
+
*/
|
|
1337
|
+
declare const RED: ColorComp;
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Green color. rgb(0, 1, 0, 1)
|
|
1341
|
+
*/
|
|
1342
|
+
declare const GREEN: ColorComp;
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Blue color. rgb(0, 0, 1, 1)
|
|
1346
|
+
*/
|
|
1347
|
+
declare const BLUE: ColorComp;
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Black color. rgb(0, 0, 0, 1)
|
|
1351
|
+
*/
|
|
1352
|
+
declare const BLACK: ColorComp;
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* White color. rgb(1, 1, 1, 1)
|
|
1356
|
+
*/
|
|
1357
|
+
declare const WHITE: ColorComp;
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Create color from a hex string.
|
|
1361
|
+
* @param hex Hex string in RGB, RGBA, RRGGBB or RRGGBBAA format (with optional initial #).
|
|
1362
|
+
* @returns The created color
|
|
1363
|
+
*/
|
|
1364
|
+
declare function from_hex(hex: string): ColorComp;
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Tween a value from one to another.
|
|
1368
|
+
* The transition will happen over a certain duration using a specific easing function.
|
|
1369
|
+
* @param from Start value
|
|
1370
|
+
* @param to End value
|
|
1371
|
+
* @param duration Time in seconds to go from start to end value
|
|
1372
|
+
* @param easing Which easing algorithm to use (default EASING_LINEAR)
|
|
1373
|
+
* @param set_value Function to call when the value has changed
|
|
1374
|
+
* @returns A tween object
|
|
1375
|
+
*/
|
|
1376
|
+
declare function tween(
|
|
1377
|
+
from: number,
|
|
1378
|
+
to: number,
|
|
1379
|
+
duration: number,
|
|
1380
|
+
easing: BoomEasing | undefined,
|
|
1381
|
+
set_value: (endValue: number) => void,
|
|
1382
|
+
): Tween;
|
|
1383
|
+
declare function tween(
|
|
1384
|
+
from: Vec2,
|
|
1385
|
+
to: Vec2,
|
|
1386
|
+
duration: number,
|
|
1387
|
+
easing: BoomEasing | undefined,
|
|
1388
|
+
set_value: (endValue: Vec2) => void,
|
|
1389
|
+
): Tween;
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* @noSelf
|
|
1393
|
+
*/
|
|
1394
|
+
interface Tween {
|
|
1395
|
+
/**
|
|
1396
|
+
* Register an event when finished.
|
|
1397
|
+
* @param fn The function to call when the tween has finished
|
|
1398
|
+
*/
|
|
1399
|
+
on_end(fn: () => void): void;
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Finish tween now.
|
|
1403
|
+
*/
|
|
1404
|
+
finish(): void;
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Cancel tween.
|
|
1408
|
+
*/
|
|
1409
|
+
cancel(): void;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Create a Vec2.
|
|
1414
|
+
* @param x Horizontal position
|
|
1415
|
+
* @param y Vertical position
|
|
1416
|
+
* @returns The created Vec2
|
|
1417
|
+
*/
|
|
1418
|
+
declare function vec2(x?: number, y?: number): Vec2;
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* When `vec2` is called as an object instead of as a function.
|
|
1422
|
+
*/
|
|
1423
|
+
declare namespace vec2 {
|
|
1424
|
+
/**
|
|
1425
|
+
* UP vector Vec2(0, 1)
|
|
1426
|
+
*/
|
|
1427
|
+
export const UP: Vec2;
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* RIGHT vector Vec2(1, 0)
|
|
1431
|
+
*/
|
|
1432
|
+
export const RIGHT: Vec2;
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* DOWN vector Vec2(0, -1)
|
|
1436
|
+
*/
|
|
1437
|
+
export const DOWN: Vec2;
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* LEFT vector Vec2(-1, 0)
|
|
1441
|
+
*/
|
|
1442
|
+
export const LEFT: Vec2;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* UP vector Vec2(0, 1)
|
|
1447
|
+
*/
|
|
1448
|
+
declare const UP: Vec2;
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* RIGHT vector Vec2(1, 0)
|
|
1452
|
+
*/
|
|
1453
|
+
declare const RIGHT: Vec2;
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* DOWN vector Vec2(0, -1)
|
|
1457
|
+
*/
|
|
1458
|
+
declare const DOWN: Vec2;
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* LEFT vector Vec2(-1, 0)
|
|
1462
|
+
*/
|
|
1463
|
+
declare const LEFT: Vec2;
|
|
1464
|
+
|
|
1465
|
+
//
|
|
1466
|
+
// Scene
|
|
1467
|
+
//
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Create a scene.
|
|
1471
|
+
* @param id Unique id of the scene
|
|
1472
|
+
* @param fn The scene code
|
|
1473
|
+
*/
|
|
1474
|
+
declare function scene(id: string, fn: (...args: unknown[]) => void): void;
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Show a scene.
|
|
1478
|
+
* @param id Id of the scene to show
|
|
1479
|
+
* @param args Additional arguments to pass to the scene function
|
|
1480
|
+
*/
|
|
1481
|
+
declare function show(id: string, ...args: unknown[]): void;
|
|
1482
|
+
|
|
1483
|
+
//
|
|
1484
|
+
// Timer
|
|
1485
|
+
//
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Run a callback after a certain number of seconds.
|
|
1489
|
+
* @param seconds Number of seconds to wait
|
|
1490
|
+
* @param cb Function to call
|
|
1491
|
+
* @returns Call to cancel the timer
|
|
1492
|
+
*/
|
|
1493
|
+
declare function wait(seconds: number, cb: () => void): BoomCancelEvent;
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Run a callback repeatedly with a certain interval.
|
|
1497
|
+
* @param seconds Interval between calls
|
|
1498
|
+
* @param cb Function to call
|
|
1499
|
+
* @returns Call to cancel the timer
|
|
1500
|
+
*/
|
|
1501
|
+
declare function loop(seconds: number, cb: () => void): BoomCancelEvent;
|
|
1502
|
+
|
|
1503
|
+
//
|
|
1504
|
+
// Info
|
|
1505
|
+
//
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* Check if a certain key is down.
|
|
1509
|
+
* @param key_id The key that must be down, or undefined for any key
|
|
1510
|
+
* @returns True if down
|
|
1511
|
+
*/
|
|
1512
|
+
declare function is_key_down(key_id?: BoomKeyboardKey): boolean;
|
|
1513
|
+
|
|
1514
|
+
/**
|
|
1515
|
+
* Get mouse position (screen coordinates).
|
|
1516
|
+
* @returns Mouse position
|
|
1517
|
+
*/
|
|
1518
|
+
declare function mouse_pos(): Vec2;
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* Get or set camera position.
|
|
1522
|
+
* @param x
|
|
1523
|
+
* @param y
|
|
1524
|
+
* @returns Camera position
|
|
1525
|
+
*/
|
|
1526
|
+
declare function cam_pos(x: number | Vec2, y?: number): void;
|
|
1527
|
+
declare function cam_pos(): Vec2;
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Get or set camera rotation.
|
|
1531
|
+
* @param angle The angle to set or undefined to get current rotation
|
|
1532
|
+
* @returns The camera rotation in degrees
|
|
1533
|
+
*/
|
|
1534
|
+
declare function cam_rot(angle: number): void;
|
|
1535
|
+
declare function cam_rot(): number;
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Get or set the camera zoom.
|
|
1539
|
+
* @param zoom The zoom to set or undefined to get the current zoom.
|
|
1540
|
+
* @returns The camera zoom
|
|
1541
|
+
*/
|
|
1542
|
+
declare function cam_zoom(zoom: number): void;
|
|
1543
|
+
declare function cam_zoom(): number;
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* Get gravity.
|
|
1547
|
+
* @returns The gravity in pixels per seconds
|
|
1548
|
+
*/
|
|
1549
|
+
declare function get_gravity(): number;
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Set gravity.
|
|
1553
|
+
* @param gravity Gravity in pixels per seconds
|
|
1554
|
+
*/
|
|
1555
|
+
declare function set_gravity(gravity: number): void;
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Get screen width.
|
|
1559
|
+
* @returns Width of screen
|
|
1560
|
+
*/
|
|
1561
|
+
declare function width(): number;
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* Get screen height.
|
|
1565
|
+
* @returns Height of screen
|
|
1566
|
+
*/
|
|
1567
|
+
declare function height(): number;
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Get screen center position.
|
|
1571
|
+
* @returns Center of screen
|
|
1572
|
+
*/
|
|
1573
|
+
declare function center(): Vec2;
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Get the delta time.
|
|
1577
|
+
* @returns Delta time
|
|
1578
|
+
*/
|
|
1579
|
+
declare function dt(): number;
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Get time since start.
|
|
1583
|
+
* @returns Time since start in seconds
|
|
1584
|
+
*/
|
|
1585
|
+
declare function time(): number;
|