@defold-typescript/types 0.5.4 → 0.6.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/api-targets.json +1 -1
- package/generated/b2d.d.ts +3 -0
- package/generated/buffer.d.ts +44 -38
- package/generated/builtin-messages.d.ts +1 -1
- package/generated/camera.d.ts +3 -0
- package/generated/collectionfactory.d.ts +47 -40
- package/generated/collectionproxy.d.ts +23 -18
- package/generated/crash.d.ts +3 -0
- package/generated/factory.d.ts +32 -24
- package/generated/go.d.ts +293 -293
- package/generated/graphics.d.ts +3 -0
- package/generated/gui.d.ts +303 -283
- package/generated/http.d.ts +26 -16
- package/generated/iac.d.ts +3 -0
- package/generated/iap.d.ts +6 -3
- package/generated/image.d.ts +30 -26
- package/generated/json.d.ts +36 -32
- package/generated/kinds/gui-script.d.ts +7 -5
- package/generated/kinds/render-script.d.ts +7 -5
- package/generated/kinds/script.d.ts +7 -5
- package/generated/label.d.ts +16 -9
- package/generated/liveupdate.d.ts +29 -26
- package/generated/model.d.ts +57 -45
- package/generated/msg.d.ts +12 -9
- package/generated/particlefx.d.ts +50 -34
- package/generated/physics.d.ts +153 -133
- package/generated/profiler.d.ts +45 -41
- package/generated/push.d.ts +5 -2
- package/generated/render.d.ts +410 -349
- package/generated/resource.d.ts +619 -572
- package/generated/socket.d.ts +49 -33
- package/generated/sound.d.ts +83 -72
- package/generated/sprite.d.ts +36 -32
- package/generated/sys.d.ts +198 -189
- package/generated/tilemap.d.ts +43 -39
- package/generated/timer.d.ts +42 -36
- package/generated/vmath.d.ts +254 -229
- package/generated/webview.d.ts +3 -0
- package/generated/window.d.ts +23 -17
- package/generated/zlib.d.ts +15 -12
- package/index.d.ts +3 -1
- package/package.json +6 -2
- package/scripts/example-store-io.ts +18 -0
- package/scripts/fidelity-audit.ts +61 -1
- package/scripts/fidelity-baseline.json +10 -10
- package/scripts/ref-doc-delta.ts +143 -0
- package/scripts/regen.ts +23 -10
- package/src/core-types.ts +14 -0
- package/src/doc-comment.ts +2 -1
- package/src/emit-dts.ts +238 -18
- package/src/engine-globals.d.ts +2 -0
- package/src/example-store.ts +44 -0
- package/src/go-overloads.d.ts +73 -0
- package/src/index.ts +5 -0
- package/src/lifecycle.ts +157 -16
- package/src/message-dispatch.d.ts +21 -0
- package/src/message-guard.d.ts +19 -0
- package/src/msg-overloads.d.ts +20 -0
- package/src/publish-dts.ts +1 -1
package/generated/socket.d.ts
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
import type { Opaque } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* [LuaSocket](https://github.com/diegonehab/luasocket) is a Lua extension library that provides
|
|
7
|
+
* support for the TCP and UDP transport layers. Defold provides the "socket" namespace in
|
|
8
|
+
* runtime, which contain the core C functionality. Additional LuaSocket support modules for
|
|
9
|
+
* SMTP, HTTP, FTP etc are not part of the core included, but can be easily added to a project
|
|
10
|
+
* and used.
|
|
11
|
+
* [icon:html5] On HTML5, the non-network helpers remain available, but TCP, UDP and
|
|
12
|
+
* `socket.select()` are not supported.
|
|
13
|
+
* Note the included helper module "socket.lua" in "builtins/scripts/socket.lua". Require this
|
|
14
|
+
* module to add some additional functions and shortcuts to the namespace:
|
|
15
|
+
* ```lua
|
|
16
|
+
* require "builtins.scripts.socket"
|
|
17
|
+
* ```
|
|
18
|
+
* LuaSocket is Copyright © 2004-2007 Diego Nehab. All rights reserved.
|
|
19
|
+
* LuaSocket is free software, released under the MIT license (same license as the Lua core).
|
|
20
|
+
*/
|
|
5
21
|
namespace socket {
|
|
6
22
|
type client = Opaque<"client">;
|
|
7
23
|
type master = Opaque<"master">;
|
|
@@ -34,11 +50,11 @@ declare global {
|
|
|
34
50
|
*
|
|
35
51
|
* @returns the number of seconds elapsed.
|
|
36
52
|
* @example
|
|
37
|
-
* ```
|
|
38
|
-
* How to use the gettime() function to measure running time:
|
|
39
|
-
* t = socket.gettime()
|
|
40
|
-
*
|
|
41
|
-
* print(socket.gettime() - t
|
|
53
|
+
* ```ts
|
|
54
|
+
* // How to use the gettime() function to measure running time:
|
|
55
|
+
* const t = socket.gettime();
|
|
56
|
+
* // do stuff
|
|
57
|
+
* print(`${socket.gettime() - t} seconds elapsed`);
|
|
42
58
|
* ```
|
|
43
59
|
*/
|
|
44
60
|
function gettime(): number;
|
|
@@ -49,16 +65,16 @@ declare global {
|
|
|
49
65
|
* @param finalizer - a function that will be called before the try throws the exception.
|
|
50
66
|
* @returns the customized try function.
|
|
51
67
|
* @example
|
|
52
|
-
* ```
|
|
53
|
-
* Perform operations on an open socket c:
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* ...
|
|
60
|
-
*
|
|
61
|
-
* c
|
|
68
|
+
* ```ts
|
|
69
|
+
* // Perform operations on an open socket c:
|
|
70
|
+
* // create a try function that closes 'c' on error
|
|
71
|
+
* const try_ = socket.newtry(() => c.close());
|
|
72
|
+
* // do everything reassured c will be closed
|
|
73
|
+
* try_(c.send("hello there?\r\n"));
|
|
74
|
+
* const answer = try_(c.receive());
|
|
75
|
+
* // ...
|
|
76
|
+
* try_(c.send("good bye\r\n"));
|
|
77
|
+
* c.close();
|
|
62
78
|
* ```
|
|
63
79
|
*/
|
|
64
80
|
function newtry(finalizer: () => void): (...args: unknown[]) => unknown;
|
|
@@ -69,17 +85,17 @@ declare global {
|
|
|
69
85
|
* @param func - a function that calls a try function (or assert, or error) to throw exceptions.
|
|
70
86
|
* @returns an equivalent function that instead of throwing exceptions, returns `nil` followed by an error message.
|
|
71
87
|
* @example
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* const dostuff = socket.protect(() => {
|
|
90
|
+
* let try_ = socket.newtry();
|
|
91
|
+
* const c = try_(socket.connect("myserver.com", 80));
|
|
92
|
+
* try_ = socket.newtry(() => c.close());
|
|
93
|
+
* try_(c.send("hello?\r\n"));
|
|
94
|
+
* const answer = try_(c.receive());
|
|
95
|
+
* c.close();
|
|
96
|
+
* });
|
|
81
97
|
*
|
|
82
|
-
*
|
|
98
|
+
* const [n, error] = dostuff();
|
|
83
99
|
* ```
|
|
84
100
|
*/
|
|
85
101
|
function protect(func: (...args: unknown[]) => unknown): (arg0: unknown) => void;
|
|
@@ -97,7 +113,7 @@ declare global {
|
|
|
97
113
|
* @param sendt - array with sockets that are watched to see if it is OK to immediately write on them.
|
|
98
114
|
* @param timeout - the maximum amount of time (in seconds) to wait for a change in status. Nil, negative or omitted timeout value allows the function to block indefinitely.
|
|
99
115
|
*/
|
|
100
|
-
function select(recvt:
|
|
116
|
+
function select(recvt: (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], sendt: (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], timeout?: number): LuaMultiReturn<[(Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], string | unknown]>;
|
|
101
117
|
/**
|
|
102
118
|
* This function drops a number of arguments and returns the remaining.
|
|
103
119
|
* It is useful to avoid creation of dummy variables:
|
|
@@ -109,14 +125,14 @@ declare global {
|
|
|
109
125
|
* @param ret2 - argument 2.
|
|
110
126
|
* @param retN - argument N.
|
|
111
127
|
* @example
|
|
112
|
-
* ```
|
|
113
|
-
* Instead of doing the following with dummy variables:
|
|
114
|
-
*
|
|
115
|
-
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* // Instead of doing the following with dummy variables:
|
|
130
|
+
* // get the status code and separator from SMTP server reply
|
|
131
|
+
* const [dummy1, dummy2, code, sep] = string.find(line, "^(%d%d%d)(.?)");
|
|
116
132
|
*
|
|
117
|
-
* You can skip a number of variables:
|
|
118
|
-
*
|
|
119
|
-
*
|
|
133
|
+
* // You can skip a number of variables:
|
|
134
|
+
* // get the status code and separator from SMTP server reply
|
|
135
|
+
* const [code, sep] = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"));
|
|
120
136
|
* ```
|
|
121
137
|
*/
|
|
122
138
|
function skip(d: number, ret1?: unknown, ret2?: unknown, retN?: unknown): LuaMultiReturn<[unknown, unknown, unknown]>;
|
package/generated/sound.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import type { Hash, Url } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions and messages for controlling sound components and
|
|
7
|
+
* mixer groups.
|
|
8
|
+
*/
|
|
5
9
|
namespace sound {
|
|
6
10
|
/**
|
|
7
11
|
* Get mixer group gain
|
|
@@ -9,10 +13,10 @@ declare global {
|
|
|
9
13
|
* @param group - group name
|
|
10
14
|
* @returns gain in [0 1] range ([-60dB.. 0dB])
|
|
11
15
|
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* Get the mixer group gain for the "soundfx" and convert to dB:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Get the mixer group gain for the "soundfx" and convert to dB:
|
|
18
|
+
* const gain = sound.get_group_gain("soundfx");
|
|
19
|
+
* const gain_db = 60 * gain;
|
|
16
20
|
* ```
|
|
17
21
|
*/
|
|
18
22
|
function get_group_gain(group: string | Hash): number;
|
|
@@ -25,13 +29,13 @@ declare global {
|
|
|
25
29
|
* @param group - group name
|
|
26
30
|
* @returns group name
|
|
27
31
|
* @example
|
|
28
|
-
* ```
|
|
29
|
-
* Get the mixer group string names so we can show them as labels on a dev mixer overlay:
|
|
30
|
-
*
|
|
31
|
-
* for
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* // Get the mixer group string names so we can show them as labels on a dev mixer overlay:
|
|
34
|
+
* const groups = sound.get_groups();
|
|
35
|
+
* for (const group of groups) {
|
|
36
|
+
* const name = sound.get_group_name(group);
|
|
37
|
+
* msg.post("/mixer_overlay#gui", "set_mixer_label", { group: group, label: name });
|
|
38
|
+
* }
|
|
35
39
|
* ```
|
|
36
40
|
*/
|
|
37
41
|
function get_group_name(group: string | Hash): string;
|
|
@@ -40,17 +44,17 @@ declare global {
|
|
|
40
44
|
*
|
|
41
45
|
* @returns table of mixer group names
|
|
42
46
|
* @example
|
|
43
|
-
* ```
|
|
44
|
-
* Get the mixer groups, set all gains to 0 except for "master" and "soundfx"
|
|
45
|
-
* where gain is set to 1:
|
|
46
|
-
*
|
|
47
|
-
* for
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Get the mixer groups, set all gains to 0 except for "master" and "soundfx"
|
|
49
|
+
* // where gain is set to 1:
|
|
50
|
+
* const groups = sound.get_groups();
|
|
51
|
+
* for (const group of groups) {
|
|
52
|
+
* if (group === hash("master") || group === hash("soundfx")) {
|
|
53
|
+
* sound.set_group_gain(group, 1);
|
|
54
|
+
* } else {
|
|
55
|
+
* sound.set_group_gain(group, 0);
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
54
58
|
* ```
|
|
55
59
|
*/
|
|
56
60
|
function get_groups(): Hash[];
|
|
@@ -66,11 +70,11 @@ declare global {
|
|
|
66
70
|
* @param group - group name
|
|
67
71
|
* @param window - window length in seconds
|
|
68
72
|
* @example
|
|
69
|
-
* ```
|
|
70
|
-
* Get the peak gain from the "master" group and convert to dB for displaying:
|
|
71
|
-
*
|
|
72
|
-
* left_p_db = 20 * log(left_p)
|
|
73
|
-
* right_p_db = 20 * log(right_p)
|
|
73
|
+
* ```ts
|
|
74
|
+
* // Get the peak gain from the "master" group and convert to dB for displaying:
|
|
75
|
+
* const [left_p, right_p] = sound.get_peak("master", 0.1);
|
|
76
|
+
* const left_p_db = 20 * Math.log(left_p);
|
|
77
|
+
* const right_p_db = 20 * Math.log(right_p);
|
|
74
78
|
* ```
|
|
75
79
|
*/
|
|
76
80
|
function get_peak(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
|
|
@@ -86,10 +90,10 @@ declare global {
|
|
|
86
90
|
* @param group - group name
|
|
87
91
|
* @param window - window length in seconds
|
|
88
92
|
* @example
|
|
89
|
-
* ```
|
|
90
|
-
* Get the RMS from the "master" group where a mono -1.94 dB sinewave is playing:
|
|
91
|
-
*
|
|
92
|
-
* print(rms)
|
|
93
|
+
* ```ts
|
|
94
|
+
* // Get the RMS from the "master" group where a mono -1.94 dB sinewave is playing:
|
|
95
|
+
* const [rms] = sound.get_rms("master", 0.1); // throw away right channel.
|
|
96
|
+
* print(rms); // => 0.56555819511414
|
|
93
97
|
* ```
|
|
94
98
|
*/
|
|
95
99
|
function get_rms(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
|
|
@@ -109,12 +113,12 @@ declare global {
|
|
|
109
113
|
*
|
|
110
114
|
* @returns `true` if music is playing, otherwise `false`.
|
|
111
115
|
* @example
|
|
112
|
-
* ```
|
|
113
|
-
* If music is playing, mute "master":
|
|
114
|
-
* if sound.is_music_playing()
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* // If music is playing, mute "master":
|
|
118
|
+
* if (sound.is_music_playing()) {
|
|
119
|
+
* // mute "master"
|
|
120
|
+
* sound.set_group_gain("master", 0);
|
|
121
|
+
* }
|
|
118
122
|
* ```
|
|
119
123
|
*/
|
|
120
124
|
function is_music_playing(): boolean;
|
|
@@ -126,11 +130,11 @@ declare global {
|
|
|
126
130
|
*
|
|
127
131
|
* @returns `true` if there is an active phone call, `false` otherwise.
|
|
128
132
|
* @example
|
|
129
|
-
* ```
|
|
130
|
-
* Test if a phone call is on-going:
|
|
131
|
-
* if sound.is_phone_call_active()
|
|
132
|
-
*
|
|
133
|
-
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* // Test if a phone call is on-going:
|
|
135
|
+
* if (sound.is_phone_call_active()) {
|
|
136
|
+
* // do something sensible.
|
|
137
|
+
* }
|
|
134
138
|
* ```
|
|
135
139
|
*/
|
|
136
140
|
function is_phone_call_active(): boolean;
|
|
@@ -140,9 +144,10 @@ declare global {
|
|
|
140
144
|
* @param url - the sound that should pause
|
|
141
145
|
* @param pause - true if the sound should pause
|
|
142
146
|
* @example
|
|
143
|
-
* ```
|
|
144
|
-
* Assuming the script belongs to an instance with a sound-component with id
|
|
145
|
-
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* // Assuming the script belongs to an instance with a sound-component with id
|
|
149
|
+
* // "sound", this will make the component pause all playing voices:
|
|
150
|
+
* sound.pause("#sound", true);
|
|
146
151
|
* ```
|
|
147
152
|
*/
|
|
148
153
|
function pause(url: string | Hash | Url, pause: boolean): void;
|
|
@@ -176,21 +181,24 @@ declare global {
|
|
|
176
181
|
* url The invoker of the callback: the sound component.
|
|
177
182
|
* @returns The identifier for the sound voice
|
|
178
183
|
* @example
|
|
179
|
-
* ```
|
|
180
|
-
* Assuming the script belongs to an instance with a sound-component with id
|
|
181
|
-
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* // Assuming the script belongs to an instance with a sound-component with id
|
|
186
|
+
* // "sound", this will make the component play its sound after 1 second:
|
|
187
|
+
* sound.play("#sound", { delay: 1, gain: 0.9, pan: -1.0 });
|
|
182
188
|
*
|
|
183
|
-
* Using the callback argument, you can chain several sounds together:
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* if message_id
|
|
187
|
-
* sound.play("#boom",
|
|
188
|
-
*
|
|
189
|
-
*
|
|
189
|
+
* // Using the callback argument, you can chain several sounds together:
|
|
190
|
+
* function sound_done(self, message_id, message, sender) {
|
|
191
|
+
* // play 'boom' sound fx when the countdown has completed
|
|
192
|
+
* if (message_id === hash("sound_done") && message.play_id === self.countdown_id) {
|
|
193
|
+
* sound.play("#boom", undefined, sound_done);
|
|
194
|
+
* }
|
|
195
|
+
* }
|
|
190
196
|
*
|
|
191
|
-
*
|
|
192
|
-
* self
|
|
193
|
-
*
|
|
197
|
+
* export default defineScript({
|
|
198
|
+
* init(self) {
|
|
199
|
+
* self.countdown_id = sound.play("#countdown", undefined, sound_done);
|
|
200
|
+
* },
|
|
201
|
+
* });
|
|
194
202
|
* ```
|
|
195
203
|
*/
|
|
196
204
|
function play(url: string | Hash | Url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number; start_time?: number; start_frame?: number }, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void): number;
|
|
@@ -200,9 +208,10 @@ declare global {
|
|
|
200
208
|
* @param url - the sound to set the gain of
|
|
201
209
|
* @param gain - sound gain between 0 and 1 [-60dB .. 0dB]. The final gain of the sound will be a combination of this gain, the group gain and the master gain.
|
|
202
210
|
* @example
|
|
203
|
-
* ```
|
|
204
|
-
* Assuming the script belongs to an instance with a sound-component with id
|
|
205
|
-
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* // Assuming the script belongs to an instance with a sound-component with id
|
|
213
|
+
* // "sound", this will set the gain to 0.9
|
|
214
|
+
* sound.set_gain("#sound", 0.9);
|
|
206
215
|
* ```
|
|
207
216
|
*/
|
|
208
217
|
function set_gain(url: string | Hash | Url, gain?: number): void;
|
|
@@ -212,9 +221,9 @@ declare global {
|
|
|
212
221
|
* @param group - group name
|
|
213
222
|
* @param gain - gain in range [0..1] mapped to [0 .. -60dB]
|
|
214
223
|
* @example
|
|
215
|
-
* ```
|
|
216
|
-
* Set mixer group gain on the "soundfx" group to 50% (-30dB):
|
|
217
|
-
* sound.set_group_gain("soundfx", 0.5)
|
|
224
|
+
* ```ts
|
|
225
|
+
* // Set mixer group gain on the "soundfx" group to 50% (-30dB):
|
|
226
|
+
* sound.set_group_gain("soundfx", 0.5);
|
|
218
227
|
* ```
|
|
219
228
|
*/
|
|
220
229
|
function set_group_gain(group: string | Hash, gain: number): void;
|
|
@@ -225,9 +234,10 @@ declare global {
|
|
|
225
234
|
* @param url - the sound to set the panning value to
|
|
226
235
|
* @param pan - sound panning between -1.0 and 1.0
|
|
227
236
|
* @example
|
|
228
|
-
* ```
|
|
229
|
-
* Assuming the script belongs to an instance with a sound-component with id
|
|
230
|
-
*
|
|
237
|
+
* ```ts
|
|
238
|
+
* // Assuming the script belongs to an instance with a sound-component with id
|
|
239
|
+
* // "sound", this will set the gain to 0.5
|
|
240
|
+
* sound.set_pan("#sound", 0.5); // pan to the right
|
|
231
241
|
* ```
|
|
232
242
|
*/
|
|
233
243
|
function set_pan(url: string | Hash | Url, pan?: number): void;
|
|
@@ -239,11 +249,12 @@ declare global {
|
|
|
239
249
|
* `play_id`
|
|
240
250
|
* number the sequential play identifier that should be stopped (was given by the sound.play() function)
|
|
241
251
|
* @example
|
|
242
|
-
* ```
|
|
243
|
-
* Assuming the script belongs to an instance with a sound-component with id
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* sound.
|
|
252
|
+
* ```ts
|
|
253
|
+
* // Assuming the script belongs to an instance with a sound-component with id
|
|
254
|
+
* // "sound", this will make the component stop all playing voices:
|
|
255
|
+
* sound.stop("#sound");
|
|
256
|
+
* const id = sound.play("#sound");
|
|
257
|
+
* sound.stop("#sound", { play_id: id });
|
|
247
258
|
* ```
|
|
248
259
|
*/
|
|
249
260
|
function stop(url: string | Hash | Url, stop_properties?: { play_id?: number }): void;
|
package/generated/sprite.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import type { Hash, Url, Vector3, Vector4 } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions, messages and properties used to manipulate sprite components.
|
|
7
|
+
*/
|
|
5
8
|
namespace sprite {
|
|
6
9
|
/**
|
|
7
10
|
* Play an animation on a sprite component from its tile set
|
|
@@ -28,22 +31,20 @@ declare global {
|
|
|
28
31
|
* `playback_rate`
|
|
29
32
|
* number the rate with which the animation will be played. Must be positive.
|
|
30
33
|
* @example
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* sprite.play_flipbook(url, "jump", anim_done)
|
|
46
|
-
* end
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Assuming the sprite has id "sprite": play the "jump" animation followed by the
|
|
36
|
+
* // "run" animation:
|
|
37
|
+
* export default defineScript({
|
|
38
|
+
* init() {
|
|
39
|
+
* const url = msg.url("#sprite");
|
|
40
|
+
* sprite.play_flipbook(url, "jump", (self, message_id, message) => {
|
|
41
|
+
* if (message_id === hash("animation_done") && message.id === hash("jump")) {
|
|
42
|
+
* // jump animation done, chain with "run"
|
|
43
|
+
* sprite.play_flipbook(url, "run");
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* },
|
|
47
|
+
* });
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
50
|
function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
|
|
@@ -55,14 +56,15 @@ declare global {
|
|
|
55
56
|
* @param url - the sprite that should flip its animations
|
|
56
57
|
* @param flip - `true` if the sprite should flip its animations, `false` if not
|
|
57
58
|
* @example
|
|
58
|
-
* ```
|
|
59
|
-
* How to flip a sprite so it faces the horizontal movement
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* // How to flip a sprite so it faces the horizontal movement (it is assumed that
|
|
61
|
+
* // the sprite component has id "sprite" and the original animation faces right):
|
|
62
|
+
* export default defineScript({
|
|
63
|
+
* update(self, dt) {
|
|
64
|
+
* // calculate self.velocity somehow
|
|
65
|
+
* sprite.set_hflip("#sprite", self.velocity.x < 0);
|
|
66
|
+
* },
|
|
67
|
+
* });
|
|
66
68
|
* ```
|
|
67
69
|
*/
|
|
68
70
|
function set_hflip(url: string | Hash | Url, flip: boolean): void;
|
|
@@ -74,14 +76,16 @@ declare global {
|
|
|
74
76
|
* @param url - the sprite that should flip its animations
|
|
75
77
|
* @param flip - `true` if the sprite should flip its animations, `false` if not
|
|
76
78
|
* @example
|
|
77
|
-
* ```
|
|
78
|
-
* How to flip a sprite in a game which negates gravity as a game mechanic
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* // How to flip a sprite in a game which negates gravity as a game mechanic (it is
|
|
81
|
+
* // assumed that the sprite component has id "sprite" and the original animation
|
|
82
|
+
* // is up-right):
|
|
83
|
+
* export default defineScript({
|
|
84
|
+
* update(self, dt) {
|
|
85
|
+
* // calculate self.up_side_down somehow, then:
|
|
86
|
+
* sprite.set_vflip("#sprite", self.up_side_down);
|
|
87
|
+
* },
|
|
88
|
+
* });
|
|
85
89
|
* ```
|
|
86
90
|
*/
|
|
87
91
|
function set_vflip(url: string | Hash | Url, flip: boolean): void;
|