@defold-typescript/types 0.5.3 → 0.5.5

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.
@@ -28,22 +28,20 @@ declare global {
28
28
  * `playback_rate`
29
29
  * number the rate with which the animation will be played. Must be positive.
30
30
  * @example
31
- * ```lua
32
- * The following examples assumes that the model has id "sprite".
33
- * How to play the "jump" animation followed by the "run" animation:
34
- * local function anim_done(self, message_id, message, sender)
35
- * if message_id == hash("animation_done") then
36
- * if message.id == hash("jump") then
37
- * -- jump animation done, chain with "run"
38
- * sprite.play_flipbook(url, "run")
39
- * end
40
- * end
41
- * end
42
- *
43
- * function init(self)
44
- * local url = msg.url("#sprite")
45
- * sprite.play_flipbook(url, "jump", anim_done)
46
- * end
31
+ * ```ts
32
+ * // Assuming the sprite has id "sprite": play the "jump" animation followed by the
33
+ * // "run" animation:
34
+ * export default defineScript({
35
+ * init() {
36
+ * const url = msg.url("#sprite");
37
+ * sprite.play_flipbook(url, "jump", (self, message_id, message) => {
38
+ * if (message_id === hash("animation_done") && message.id === hash("jump")) {
39
+ * // jump animation done, chain with "run"
40
+ * sprite.play_flipbook(url, "run");
41
+ * }
42
+ * });
43
+ * },
44
+ * });
47
45
  * ```
48
46
  */
49
47
  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 +53,15 @@ declare global {
55
53
  * @param url - the sprite that should flip its animations
56
54
  * @param flip - `true` if the sprite should flip its animations, `false` if not
57
55
  * @example
58
- * ```lua
59
- * How to flip a sprite so it faces the horizontal movement:
60
- * function update(self, dt)
61
- * -- calculate self.velocity somehow
62
- * sprite.set_hflip("#sprite", self.velocity.x < 0)
63
- * end
64
- *
65
- * It is assumed that the sprite component has id "sprite" and that the original animations faces right.
56
+ * ```ts
57
+ * // How to flip a sprite so it faces the horizontal movement (it is assumed that
58
+ * // the sprite component has id "sprite" and the original animation faces right):
59
+ * export default defineScript({
60
+ * update(self, dt) {
61
+ * // calculate self.velocity somehow
62
+ * sprite.set_hflip("#sprite", self.velocity.x < 0);
63
+ * },
64
+ * });
66
65
  * ```
67
66
  */
68
67
  function set_hflip(url: string | Hash | Url, flip: boolean): void;
@@ -74,14 +73,16 @@ declare global {
74
73
  * @param url - the sprite that should flip its animations
75
74
  * @param flip - `true` if the sprite should flip its animations, `false` if not
76
75
  * @example
77
- * ```lua
78
- * How to flip a sprite in a game which negates gravity as a game mechanic:
79
- * function update(self, dt)
80
- * -- calculate self.up_side_down somehow, then:
81
- * sprite.set_vflip("#sprite", self.up_side_down)
82
- * end
83
- *
84
- * It is assumed that the sprite component has id "sprite" and that the original animations are up-right.
76
+ * ```ts
77
+ * // How to flip a sprite in a game which negates gravity as a game mechanic (it is
78
+ * // assumed that the sprite component has id "sprite" and the original animation
79
+ * // is up-right):
80
+ * export default defineScript({
81
+ * update(self, dt) {
82
+ * // calculate self.up_side_down somehow, then:
83
+ * sprite.set_vflip("#sprite", self.up_side_down);
84
+ * },
85
+ * });
85
86
  * ```
86
87
  */
87
88
  function set_vflip(url: string | Hash | Url, flip: boolean): void;