melonjs 20.8.0 → 20.9.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.
Files changed (182) hide show
  1. package/README.md +1 -0
  2. package/build/application/application.d.ts +66 -8
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/defaultApplicationSettings.d.ts +1 -0
  5. package/build/application/defaultApplicationSettings.d.ts.map +1 -1
  6. package/build/application/resize.d.ts +25 -0
  7. package/build/application/resize.d.ts.map +1 -1
  8. package/build/application/scaleMethods.d.ts +13 -3
  9. package/build/application/scaleMethods.d.ts.map +1 -1
  10. package/build/application/settings.d.ts +56 -5
  11. package/build/application/settings.d.ts.map +1 -1
  12. package/build/audio/audio.d.ts +29 -5
  13. package/build/audio/audio.d.ts.map +1 -1
  14. package/build/audio/autopause.d.ts +36 -0
  15. package/build/audio/autopause.d.ts.map +1 -0
  16. package/build/audio/backend/engine.d.ts +10 -0
  17. package/build/audio/backend/engine.d.ts.map +1 -1
  18. package/build/audio/backend/sound.d.ts.map +1 -1
  19. package/build/audio/backend/spatial.d.ts.map +1 -1
  20. package/build/audio/context.d.ts +35 -0
  21. package/build/audio/context.d.ts.map +1 -0
  22. package/build/audio/playback.d.ts.map +1 -1
  23. package/build/audio/procedural.d.ts.map +1 -1
  24. package/build/audio/spatial.d.ts +87 -0
  25. package/build/audio/spatial.d.ts.map +1 -0
  26. package/build/audio/state.d.ts +1 -0
  27. package/build/audio/state.d.ts.map +1 -1
  28. package/build/audio/types.d.ts +46 -6
  29. package/build/audio/types.d.ts.map +1 -1
  30. package/build/camera/camera2d.d.ts.map +1 -1
  31. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  32. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  33. package/build/camera/effects/shake_effect.d.ts.map +1 -1
  34. package/build/geometries/box3d.d.ts +1 -1
  35. package/build/geometries/box3d.d.ts.map +1 -1
  36. package/build/geometries/ellipse.d.ts +1 -1
  37. package/build/geometries/ellipse.d.ts.map +1 -1
  38. package/build/geometries/line.d.ts +1 -1
  39. package/build/geometries/line.d.ts.map +1 -1
  40. package/build/geometries/point.d.ts +1 -1
  41. package/build/geometries/point.d.ts.map +1 -1
  42. package/build/geometries/polygon.d.ts +1 -1
  43. package/build/geometries/polygon.d.ts.map +1 -1
  44. package/build/geometries/rectangle.d.ts +1 -1
  45. package/build/geometries/rectangle.d.ts.map +1 -1
  46. package/build/geometries/roundrect.d.ts +1 -1
  47. package/build/geometries/roundrect.d.ts.map +1 -1
  48. package/build/geometries/sphere.d.ts +1 -1
  49. package/build/geometries/sphere.d.ts.map +1 -1
  50. package/build/index.d.ts +8 -2
  51. package/build/index.d.ts.map +1 -1
  52. package/build/index.js +36985 -34678
  53. package/build/index.js.map +4 -4
  54. package/build/input/gamepad.d.ts +129 -3
  55. package/build/input/gamepad.d.ts.map +1 -1
  56. package/build/level/gltf/GLTFModel.d.ts +5 -4
  57. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  58. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  59. package/build/level/tiled/TMXObjectFactory.d.ts +3 -2
  60. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  61. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  62. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +1 -4
  63. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  64. package/build/loader/cache.d.ts +220 -0
  65. package/build/loader/cache.d.ts.map +1 -1
  66. package/build/loader/loader.d.ts +20 -349
  67. package/build/loader/loader.d.ts.map +1 -1
  68. package/build/loader/parsers/gltf.d.ts +115 -0
  69. package/build/loader/parsers/gltf.d.ts.map +1 -1
  70. package/build/math/color.d.ts +1 -1
  71. package/build/math/color.d.ts.map +1 -1
  72. package/build/math/matrix2d.d.ts +1 -1
  73. package/build/math/matrix2d.d.ts.map +1 -1
  74. package/build/math/matrix3d.d.ts +1 -1
  75. package/build/math/matrix3d.d.ts.map +1 -1
  76. package/build/math/observableVector2d.d.ts +14 -2
  77. package/build/math/observableVector2d.d.ts.map +1 -1
  78. package/build/math/observableVector3d.d.ts +15 -1
  79. package/build/math/observableVector3d.d.ts.map +1 -1
  80. package/build/math/vector2d.d.ts +31 -1
  81. package/build/math/vector2d.d.ts.map +1 -1
  82. package/build/math/vector3d.d.ts +38 -1
  83. package/build/math/vector3d.d.ts.map +1 -1
  84. package/build/math/vertex.d.ts.map +1 -1
  85. package/build/particles/emitter.d.ts.map +1 -1
  86. package/build/particles/particle.d.ts +7 -1
  87. package/build/particles/particle.d.ts.map +1 -1
  88. package/build/particles/settings.d.ts +35 -0
  89. package/build/particles/settings.d.ts.map +1 -1
  90. package/build/physics/bounds.d.ts +1 -1
  91. package/build/physics/bounds.d.ts.map +1 -1
  92. package/build/physics/broadphase/octree.d.ts +24 -0
  93. package/build/physics/broadphase/octree.d.ts.map +1 -1
  94. package/build/physics/broadphase/quadtree.d.ts +31 -0
  95. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  96. package/build/physics/builtin/body.d.ts +14 -0
  97. package/build/physics/builtin/body.d.ts.map +1 -1
  98. package/build/pool.d.ts +4 -0
  99. package/build/pool.d.ts.map +1 -1
  100. package/build/renderable/colorlayer.d.ts +13 -0
  101. package/build/renderable/colorlayer.d.ts.map +1 -1
  102. package/build/renderable/container.d.ts.map +1 -1
  103. package/build/renderable/groundshadow.d.ts.map +1 -1
  104. package/build/renderable/instanced_mesh.d.ts +56 -0
  105. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  106. package/build/renderable/mesh.d.ts +97 -11
  107. package/build/renderable/mesh.d.ts.map +1 -1
  108. package/build/renderable/renderable.d.ts +41 -3
  109. package/build/renderable/renderable.d.ts.map +1 -1
  110. package/build/renderable/sprite.d.ts +2 -1
  111. package/build/renderable/sprite.d.ts.map +1 -1
  112. package/build/renderable/sprite3d.d.ts +6 -2
  113. package/build/renderable/sprite3d.d.ts.map +1 -1
  114. package/build/renderable/text/bitmaptext.d.ts +63 -2
  115. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  116. package/build/renderable/text/bitmaptextdata.d.ts +1 -1
  117. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  118. package/build/renderable/text/glypheffect.d.ts +44 -0
  119. package/build/renderable/text/glypheffect.d.ts.map +1 -0
  120. package/build/renderable/text/text.d.ts +17 -0
  121. package/build/renderable/text/text.d.ts.map +1 -1
  122. package/build/renderable/trail.d.ts.map +1 -1
  123. package/build/renderable/trail3d.d.ts +174 -0
  124. package/build/renderable/trail3d.d.ts.map +1 -0
  125. package/build/renderable/trigger.d.ts +2 -1
  126. package/build/renderable/trigger.d.ts.map +1 -1
  127. package/build/renderable/ui/panelpaint.d.ts +5 -0
  128. package/build/renderable/ui/panelpaint.d.ts.map +1 -0
  129. package/build/renderable/ui/progressbar.d.ts +2 -4
  130. package/build/renderable/ui/progressbar.d.ts.map +1 -1
  131. package/build/renderable/ui/uipanel.d.ts +245 -0
  132. package/build/renderable/ui/uipanel.d.ts.map +1 -0
  133. package/build/renderable/ui/uitextbutton.d.ts +30 -1
  134. package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
  135. package/build/state/state.d.ts.map +1 -1
  136. package/build/system/bootstrap.d.ts.map +1 -1
  137. package/build/system/legacy_pool.d.ts +22 -2
  138. package/build/system/legacy_pool.d.ts.map +1 -1
  139. package/build/system/pool.d.ts +5 -8
  140. package/build/system/pool.d.ts.map +1 -1
  141. package/build/tweens/tween.d.ts +1 -1
  142. package/build/tweens/tween.d.ts.map +1 -1
  143. package/build/video/effects/tintPulse.d.ts +0 -5
  144. package/build/video/effects/tintPulse.d.ts.map +1 -1
  145. package/build/video/effects/wave.d.ts +0 -5
  146. package/build/video/effects/wave.d.ts.map +1 -1
  147. package/build/video/gpu/batcher.d.ts +8 -2
  148. package/build/video/gpu/batcher.d.ts.map +1 -1
  149. package/build/video/gradient.d.ts +1 -0
  150. package/build/video/gradient.d.ts.map +1 -1
  151. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  152. package/build/video/rendertarget/rendertarget.d.ts +12 -5
  153. package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
  154. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  155. package/build/video/rendertarget/webgpurendertarget.d.ts +6 -12
  156. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  157. package/build/video/texture/atlas.d.ts +1 -1
  158. package/build/video/texture/atlas.d.ts.map +1 -1
  159. package/build/video/texture/texture2d.d.ts +6 -0
  160. package/build/video/texture/texture2d.d.ts.map +1 -1
  161. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -11
  162. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  163. package/package.json +2 -2
  164. package/skills/AGENTS.md +1 -1
  165. package/skills/melonjs/SKILL.md +2 -0
  166. package/skills/melonjs-3d/SKILL.md +192 -18
  167. package/skills/melonjs-3d-assets/SKILL.md +36 -2
  168. package/skills/melonjs-audio/SKILL.md +229 -8
  169. package/skills/melonjs-camera-and-drawing/SKILL.md +73 -3
  170. package/skills/melonjs-display-and-scaling/SKILL.md +273 -0
  171. package/skills/melonjs-effects-and-shaders/SKILL.md +4 -4
  172. package/skills/melonjs-events/SKILL.md +8 -6
  173. package/skills/melonjs-input/SKILL.md +100 -4
  174. package/skills/melonjs-math/SKILL.md +313 -0
  175. package/skills/melonjs-particles-and-trails/SKILL.md +88 -14
  176. package/skills/melonjs-performance/SKILL.md +50 -19
  177. package/skills/melonjs-physics/SKILL.md +2 -1
  178. package/skills/melonjs-renderables/SKILL.md +6 -1
  179. package/skills/melonjs-scenes-and-state/SKILL.md +14 -3
  180. package/skills/melonjs-sprites-and-animation/SKILL.md +9 -4
  181. package/skills/melonjs-tilemaps/SKILL.md +40 -12
  182. package/skills/melonjs-ui-and-text/SKILL.md +382 -4
@@ -0,0 +1,174 @@
1
+ /**
2
+ * A fading, tapering ribbon that recedes properly into a 3D scene.
3
+ *
4
+ * The 3D sibling of {@link Trail}, and a separate class for the same reason
5
+ * {@link Sprite3d} is separate from {@link Sprite}: the two draw through
6
+ * different tiers. A `Trail` emits its ribbon as 2D paths, which carry one
7
+ * depth for the whole renderable and a width measured in the screen plane, so
8
+ * it cannot narrow along its own length or lie on a surface. This one builds
9
+ * a real camera-facing strip and hands it to the mesh pipeline.
10
+ *
11
+ * It is a {@link Mesh}, so everything a mesh can do it can do: a post effect
12
+ * reaches it, `tint` multiplies it, it sorts into the transparent pass, and
13
+ * fog applies. It is also **cheaper to draw than a 2D trail** — one indexed
14
+ * draw call rather than one filled path per segment.
15
+ *
16
+ * Needs a {@link Camera3d}. Under a 2D camera it draws nothing and says so
17
+ * once, because the alternative is geometry projected twice.
18
+ * @augments Mesh
19
+ * @category Game Objects
20
+ * @example
21
+ * // an exhaust streak behind a craft
22
+ * const exhaust = new Trail3d(0, 0, {
23
+ * target: ship,
24
+ * width: 6,
25
+ * lifetime: 260,
26
+ * gradient: ["#eaffff", "#2ea8ff", "#2ea8ff00"],
27
+ * });
28
+ * exhaust.blendMode = "additive";
29
+ * app.world.addChild(exhaust);
30
+ * @example
31
+ * // a tyre mark lying in the ground plane: not camera-facing, so it keeps
32
+ * // the orientation it is given
33
+ * const skid = new Trail3d(0, 0, {
34
+ * target: car,
35
+ * width: 12,
36
+ * billboard: false,
37
+ * ribbonNormal: [0, -1, 0], // world up
38
+ * color: "#1a1a1a",
39
+ * });
40
+ * @example
41
+ * // manual mode, for a path the game computes itself
42
+ * const arc = new Trail3d(0, 0, { width: 4, lifetime: 400 });
43
+ * app.world.addChild(arc);
44
+ * // each frame while the spell travels
45
+ * arc.addPoint(bolt.pos.x, bolt.pos.y, bolt.pos.z);
46
+ * @see {@link Trail} for the 2D one
47
+ */
48
+ export default class Trail3d extends Mesh {
49
+ /**
50
+ * @param {number} x - the ribbon's initial anchor, world units. Only seeds
51
+ * the cull bounds: once there are points, the anchor follows them.
52
+ * @param {number} y - as `x`
53
+ * @param {object} [settings] - trail options
54
+ * @param {Renderable|Vector3d} [settings.target] - auto-follow target
55
+ * @param {number} [settings.length=20] - max number of points. **Fixed at
56
+ * construction**: the geometry is sized once, so this cannot grow later,
57
+ * and assigning {@link Trail3d#maxPoints} throws. A fractional value is
58
+ * truncated.
59
+ * @param {number} [settings.lifetime=500] - point lifetime in ms
60
+ * @param {number} [settings.minDistance=4] - min world distance between samples
61
+ * @param {number} [settings.width=10] - max ribbon width in world units
62
+ * @param {number[]} [settings.widthCurve=[1, 0]] - width multiplier curve (0=head, 1=tail)
63
+ * @param {Color|string} [settings.color="#ffffff"] - single colour, faded out along the ribbon. Ignored if `gradient` is set.
64
+ * @param {(Color|string|{pos: number, color: Color|string})[]} [settings.gradient] - colour gradient. Overrides `color`.
65
+ * @param {boolean|string} [settings.billboard="spherical"] - `false` (use `ribbonNormal`), `true` / `"cylindrical"` (faces the camera but stays upright), or `"spherical"` (faces the camera on all axes)
66
+ * @param {Vector3d|number[]} [settings.ribbonNormal] - the facing used when `billboard` is `false`; defaults to world up
67
+ * @param {number} [settings.opacity=1.0] - opacity (0.0–1.0)
68
+ * @param {string} [settings.blendMode="normal"] - blend mode
69
+ * @param {boolean} [settings.depthTest=true] - whether the ribbon is depth tested
70
+ * @throws {Error} when `length` is not a finite number. Silence there is
71
+ * worse than it sounds: `NaN` sizes every buffer to zero and makes the
72
+ * capacity test always false, so the ribbon never renders and the point
73
+ * list grows without bound.
74
+ */
75
+ constructor(x: number, y: number, settings?: {
76
+ target?: Vector3d | Renderable | undefined;
77
+ length?: number | undefined;
78
+ lifetime?: number | undefined;
79
+ minDistance?: number | undefined;
80
+ width?: number | undefined;
81
+ widthCurve?: number[] | undefined;
82
+ color?: string | Color | undefined;
83
+ gradient?: (string | Color | {
84
+ pos: number;
85
+ color: Color | string;
86
+ })[] | undefined;
87
+ billboard?: string | boolean | undefined;
88
+ ribbonNormal?: number[] | Vector3d | undefined;
89
+ opacity?: number | undefined;
90
+ blendMode?: string | undefined;
91
+ depthTest?: boolean | undefined;
92
+ });
93
+ /**
94
+ * what the ribbon follows, sampled once per update
95
+ * @type {Renderable|Vector3d|null}
96
+ */
97
+ target: Renderable | Vector3d | null;
98
+ /** @type {number} */
99
+ lifetime: number;
100
+ /** @type {number} */
101
+ minDistance: number;
102
+ /** @type {number[]} */
103
+ widthCurve: number[];
104
+ billboard: string | boolean;
105
+ set ribbonNormal(value: Vector3d);
106
+ /**
107
+ * The facing used when {@link Trail3d#billboard} is `false`.
108
+ *
109
+ * Accepts a {@link Vector3d} or a `[x, y, z]` array and holds a normalized
110
+ * copy, so a caller that keeps mutating the array it passed is not
111
+ * steering this ribbon by accident. A zero-length value falls back to
112
+ * world up rather than dividing by it.
113
+ * @type {Vector3d}
114
+ * @default (0, -1, 0)
115
+ */
116
+ get ribbonNormal(): Vector3d;
117
+ castGroundShadow: boolean;
118
+ set maxPoints(_value: number);
119
+ /**
120
+ * How many points the ribbon can hold.
121
+ *
122
+ * Read-only: see the note on `settings.length`. Assigning throws rather
123
+ * than silently doing nothing, because the alternative is a ribbon that
124
+ * quietly keeps its old capacity.
125
+ * @type {number}
126
+ */
127
+ get maxPoints(): number;
128
+ /**
129
+ * Recolour the ribbon with a single colour, faded out along its length.
130
+ *
131
+ * A method rather than a setter, matching {@link Renderable#setTint} and
132
+ * {@link Renderable#setOpacity}: it allocates a gradient, so it is for a
133
+ * change of state rather than for every frame. {@link Renderable#tint} is
134
+ * the per-frame lever, and unlike on {@link Trail} it works here, because
135
+ * the mesh batcher multiplies it in.
136
+ * @param {Color|string} value - the colour
137
+ * @returns {Trail3d} this, for chaining
138
+ */
139
+ setColor(value: Color | string): Trail3d;
140
+ /**
141
+ * Recolour the ribbon with a gradient, in the format the constructor takes.
142
+ * @param {(Color|string|{pos: number, color: Color|string})[]} value - the stops
143
+ * @returns {Trail3d} this, for chaining
144
+ */
145
+ setGradient(value: (Color | string | {
146
+ pos: number;
147
+ color: Color | string;
148
+ })[]): Trail3d;
149
+ /**
150
+ * The gradient the ribbon is currently coloured by.
151
+ * @type {Gradient}
152
+ * @see {@link Trail3d#setGradient}
153
+ */
154
+ get gradient(): Gradient;
155
+ /**
156
+ * Add a point to the ribbon.
157
+ *
158
+ * Ignored when it is closer than {@link Trail3d#minDistance} to the last
159
+ * one, measured in three dimensions — which is what stops a ribbon flying
160
+ * straight at the camera from never sampling a second point.
161
+ * @param {number} x - x position, world units
162
+ * @param {number} y - y position, world units
163
+ * @param {number} [z=0] - z position, world units
164
+ */
165
+ addPoint(x: number, y: number, z?: number): void;
166
+ /** drop every point, leaving the ribbon empty */
167
+ clear(): void;
168
+ }
169
+ import Mesh from "./mesh.js";
170
+ import type Renderable from "./renderable.js";
171
+ import { Vector3d } from "../math/vector3d.ts";
172
+ import type { Gradient } from "../video/gradient.js";
173
+ import type { Color } from "../math/color.ts";
174
+ //# sourceMappingURL=trail3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trail3d.d.ts","sourceRoot":"","sources":["../../src/renderable/trail3d.js"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,eAzBW,MAAM,KAEN,MAAM,aAEd;QAAuC,MAAM;QACnB,MAAM;QAIN,QAAQ;QACR,WAAW;QACX,KAAK;QACH,UAAU;QACN,KAAK;QACkC,QAAQ;iBAAnD,MAAM;mBAAS,KAAK,GAAC,MAAM;;QACrB,SAAS;QACN,YAAY;QACvB,OAAO;QACP,SAAS;QACR,SAAS;KACpC,EA+HF;IA1EA;;;OAGG;IACH,QAFU,UAAU,GAAC,QAAQ,GAAC,IAAI,CAEG;IACrC,qBAAqB;IACrB,UADW,MAAM,CACuB;IACxC,qBAAqB;IACrB,aADW,MAAM,CAC2B;IAG5C,uBAAuB;IACvB,YADW,MAAM,EAAE,CAIT;IAEV;;;OAGG;IACH,mBAAwB;IACxB;;;;;;;OAOG;IACH,eAAiB;IACjB,wBAAwB;IACxB,oBAA8C;IAC9C,wBAAwB;IACxB,qBAAoC;IACpC,6DAA6D;IAC7D,kCAA0C;IAC1C,wBAAwB;IACxB,wBAAqE;IACrE;;;;;;;;;;;OAWG;IACH,iBAAiB;IACjB,wBAAwB;IACxB,iBAAiB;IAEjB,4BAAkD;IAqDnD,wBAPU,QAAQ,EAiBjB;IAxBD;;;;;;;;;OASG;IACH,oBAHU,QAAQ,CAKjB;IAzCA,0BAA6B;IAuB9B,sBANU,MAAM,EAUf;IAhBD;;;;;;;OAOG;IACH,iBAFU,MAAM,CAIf;IAkCD;;;;;;;;;;OAUG;IACH,gBAHW,KAAK,GAAC,MAAM,GACV,OAAO,CAQnB;IAED;;;;OAIG;IACH,mBAHW,CAAC,KAAK,GAAC,MAAM,GAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,GAAC,MAAM,CAAA;KAAC,CAAC,EAAE,GACjD,OAAO,CAMnB;IAED;;;;OAIG;IACH,gBAHU,QAAQ,CAKjB;IAED;;;;;;;;;OASG;IACH,YAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;IAED,iDAAiD;IACjD,cAEC;IAuCD;;;;;;;;;;;;;;;OAeG;IACH,sBA2DC;IAED;;;;;;;;;;;;;;OAcG;IACH,wBALW,OAAO,GACL,MAAM,CAuBlB;IAED;;;;;;OAMG;IACH,eALW,QAAQ,aACR,QAAQ,QA6BlB;IAED;;;;;OAKG;IACH,sBAJW,QAAQ,QA2FlB;IAED;;;;;;;OAOG;IACH,kBAJa,MAAM,GAAC,IAAI,CAsCvB;IAwBD;;;;;;;OAOG;IACH,uBAJa,MAAM,CAwBlB;CAmBD;iBA/tBgB,WAAW;4BAMD,iBAAiB;yBATnB,qBAAqB;8BAQnB,sBAAsB;2BADzB,kBAAkB;0BAGjB,sBAAsB;qBAb1B,uBAAuB"}
@@ -88,7 +88,7 @@ export default class Trigger extends Renderable {
88
88
  shadowStretch?: number | undefined;
89
89
  shadowDirectionX?: number | undefined;
90
90
  shadowDirectionZ?: number | undefined;
91
- shadowGroundNormal?: number[] | Vector3d;
91
+ shadowGroundNormal?: number[] | Vector3d | undefined;
92
92
  shadowLight?: any;
93
93
  });
94
94
  color: any;
@@ -129,4 +129,5 @@ import type { Rect } from "../geometries/rectangle.ts";
129
129
  import type { Line } from "../geometries/line.ts";
130
130
  import type { Color } from "../math/color.ts";
131
131
  import type Container from "./container.js";
132
+ import type { Vector3d } from "../math/vector3d.ts";
132
133
  //# sourceMappingURL=trigger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/renderable/trigger.js"],"names":[],"mappings":"AAiEA;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACH,eA9DW,MAAM,KACN,MAAM,YAEd;QAA0B,KAAK;QACL,MAAM;QACqB,MAAM;QACjC,QAAQ;QACF,KAAK;QACX,UAAU;QACD,KAAK;QACd,KAAK;QACL,EAAE;QACQ,SAAS;QACjB,QAAQ;QACT,OAAO;QACP,iBAAiB;QAClB,KAAK;QACJ,WAAW;QACX,MAAM;QACP,mBAAmB;QAClB,gBAAgB;QACjB,aAAa;QACb,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QACL,kBAAkB,GAA/C,MAAM,EAAE,GAAC,QAAQ;QACE,WAAW;KACtC,EAyFF;IApDA,WAA4C;IAC5C,6BAAiC;IACjC,mBAA+C;IAC/C,+CAAqC;IACrC,gBAAmB;IAInB,UAAyB;IACzB,QAAqB;IACrB,8BAA4B;IAG5B;;MAEC;IAwBD;;;;;;MAMC;IASF;;;OAGG;IACH;;MAQC;IAED;;;OAGG;IACH,+BAwFC;IAED;;;;;OAKG;IACH,yBAIC;CACD;uBA3SsB,iBAAiB;6BASd,0BAA0B;6BAF1B,0BAA0B;0BAG7B,4BAA4B;0BAF5B,uBAAuB;2BAHtB,kBAAkB;2BAChB,gBAAgB"}
1
+ {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/renderable/trigger.js"],"names":[],"mappings":"AAkEA;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACH,eA9DW,MAAM,KACN,MAAM,YAEd;QAA0B,KAAK;QACL,MAAM;QACqB,MAAM;QACjC,QAAQ;QACF,KAAK;QACX,UAAU;QACD,KAAK;QACd,KAAK;QACL,EAAE;QACQ,SAAS;QACjB,QAAQ;QACT,OAAO;QACP,iBAAiB;QAClB,KAAK;QACJ,WAAW;QACX,MAAM;QACP,mBAAmB;QAClB,gBAAgB;QACjB,aAAa;QACb,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QACL,kBAAkB;QAC5B,WAAW;KACtC,EAyFF;IApDA,WAA4C;IAC5C,6BAAiC;IACjC,mBAA+C;IAC/C,+CAAqC;IACrC,gBAAmB;IAInB,UAAyB;IACzB,QAAqB;IACrB,8BAA4B;IAG5B;;MAEC;IAwBD;;;;;;MAMC;IASF;;;OAGG;IACH;;MAQC;IAED;;;OAGG;IACH,+BAwFC;IAED;;;;;OAKG;IACH,yBAIC;CACD;uBA5SsB,iBAAiB;6BAUd,0BAA0B;6BAH1B,0BAA0B;0BAI7B,4BAA4B;0BAH5B,uBAAuB;2BAHtB,kBAAkB;2BAChB,gBAAgB;8BAGf,qBAAqB"}
@@ -0,0 +1,5 @@
1
+ import { Color } from "../../math/color.ts";
2
+ import type { Gradient } from "../../video/gradient.js";
3
+ /** anything {@link Renderer#setColor} will take */
4
+ export type Paint = Color | string | Gradient;
5
+ //# sourceMappingURL=panelpaint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panelpaint.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/panelpaint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAa,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,mDAAmD;AACnD,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC"}
@@ -1,9 +1,8 @@
1
- import { Color } from "../../math/color.ts";
2
1
  import { on } from "../../system/event.ts";
3
- import type { Gradient } from "../../video/gradient.js";
4
2
  import type Renderer from "../../video/renderer.js";
5
3
  import Renderable from "../renderable.js";
6
4
  import Text from "../text/text.js";
5
+ import type { Paint } from "./panelpaint.ts";
7
6
  /**
8
7
  * The name of any event the engine knows about.
9
8
  *
@@ -11,8 +10,6 @@ import Text from "../text/text.js";
11
10
  * the event module; this gets the same set without widening that surface.
12
11
  */
13
12
  type EventName = Parameters<typeof on>[0];
14
- /** anything {@link Renderer#setColor} will take */
15
- type Paint = Color | string | Gradient;
16
13
  /** which way the fill grows */
17
14
  export type ProgressBarDirection = "left-to-right" | "right-to-left" | "top-to-bottom" | "bottom-to-top";
18
15
  /**
@@ -153,6 +150,7 @@ export default class ProgressBar extends Renderable {
153
150
  label?: Text | undefined;
154
151
  /** the event the value is taken from, if any */
155
152
  readonly bindEvent?: EventName | undefined;
153
+ private _value;
156
154
  /**
157
155
  * @param x - position of the bar's left edge
158
156
  * @param y - position of its top edge
@@ -1 +1 @@
1
- {"version":3,"file":"progressbar.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/progressbar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAa,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAO,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC;;;;;GA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AE,MAAM,CAAC;IACpB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAChE,0BAA0B;IAC1B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,gDAAgD;IAChD,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACzB,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAE3C,OAAO,CAAC,MAAM,CAAS;IAYvB;;;;OAIG;gBACS,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB;IAyD/D;;;;;;;;OAQG;IACH,IAAI,KAAK,IAII,MAAM,CAFlB;IAED,IAAI,KAAK,CAAC,CAAC,EAAE,MAAM,EAWlB;IAED;;;;;;OAMG;IACH,IAAI,KAAK,WAGR;IAYD;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM;IAKlB;;;OAGG;IACM,IAAI,CAAC,QAAQ,EAAE,QAAQ;CAgGhC"}
@@ -0,0 +1,245 @@
1
+ import type Camera2d from "../../camera/camera2d.ts";
2
+ import type { Matrix3d } from "../../math/matrix3d.ts";
3
+ import type { Vector3d } from "../../math/vector3d.ts";
4
+ import type Renderer from "../../video/renderer.js";
5
+ import type { Paint } from "./panelpaint.ts";
6
+ import UIBaseElement from "./uibaseelement.ts";
7
+ /**
8
+ * Everything {@link UIPanel} takes.
9
+ */
10
+ export interface UIPanelSettings {
11
+ /** the panel's width, in pixels */
12
+ width: number;
13
+ /** the panel's height, in pixels */
14
+ height: number;
15
+ /**
16
+ * The fill behind the children; `null` leaves it transparent.
17
+ *
18
+ * NOT `backgroundColor`, which a `Container` already has and which does
19
+ * something else entirely: that one is handed to `clearColor` and wipes
20
+ * the whole render target, so a panel setting it would repaint the
21
+ * screen. The name here matches {@link ProgressBarSettings} instead.
22
+ */
23
+ fillColor?: Paint | null;
24
+ /** drawn around the edge; `null` for none */
25
+ borderColor?: Paint | null;
26
+ /** how thick that border is */
27
+ borderWidth?: number;
28
+ /** corner radius; `0` is square */
29
+ radius?: number;
30
+ /**
31
+ * How far the panel drifts up and down, in pixels. `0`, the default,
32
+ * leaves it still.
33
+ *
34
+ * See {@link UIPanel#bobAmplitude}.
35
+ */
36
+ bobAmplitude?: number;
37
+ /**
38
+ * How long one full up and down cycle takes, in milliseconds.
39
+ *
40
+ * See {@link UIPanel#bobPeriod}.
41
+ */
42
+ bobPeriod?: number;
43
+ /**
44
+ * Whether the panel swallows pointer events aimed at what is behind it.
45
+ *
46
+ * `true` by default, which is what a dialog wants: a click on the panel,
47
+ * or on the dimmed scene it covers, must not reach the game underneath.
48
+ * Children are unaffected either way, because the dispatcher asks a child
49
+ * before the container holding it.
50
+ *
51
+ * Set `false` for a panel that is only a backdrop, such as a HUD frame
52
+ * drawn over a playfield that still has to receive clicks.
53
+ */
54
+ blocking?: boolean;
55
+ }
56
+ /**
57
+ * A rectangular surface with a background, an optional border and children.
58
+ *
59
+ * The thing every menu, dialog and HUD frame starts by writing: a rounded
60
+ * rectangle, a fill, an outline, and some labels on top. One example in this
61
+ * repository had three of them, each repeating the same half dozen renderer
62
+ * calls, and each repeating the same correction for the way `setColor` folds
63
+ * the global alpha in. That correction is the reason this is a widget rather
64
+ * than a snippet: it is easy to leave out, and leaving it out does not fail,
65
+ * it just renders a panel at the wrong opacity.
66
+ *
67
+ * It is a {@link UIBaseElement}, so it is a container that carries pointer
68
+ * events, and children added to it are drawn over its background and are
69
+ * asked about a click before it is.
70
+ *
71
+ * It is floating, as every UI element is, and where it lands in the paint
72
+ * order is the depth it is added at. In a world sorted on `"depth"`, which
73
+ * is every `Camera3d` scene, that depth is read the other way round from
74
+ * the 2D habit: a floating child is ranked by `|pos.z|` there and the
75
+ * SMALLER magnitude draws on top, so a panel added at 9000 to sit above
76
+ * everything sits behind everything instead, and a dialog there wants a
77
+ * small depth, 0 or 1.
78
+ * @example
79
+ * import { UIPanel, Text } from "melonjs";
80
+ *
81
+ * const panel = new UIPanel(cx - 200, cy - 120, {
82
+ * width: 400,
83
+ * height: 240,
84
+ * fillColor: "#0a1526",
85
+ * borderColor: "rgba(130, 200, 240, 0.55)",
86
+ * borderWidth: 2,
87
+ * radius: 14,
88
+ * });
89
+ * // positioned relative to the panel, not to the screen
90
+ * panel.addChild(new Text(200, 24, { text: "PAUSED", textAlign: "center" }));
91
+ * app.world.addChild(panel);
92
+ * @category UI
93
+ */
94
+ export default class UIPanel extends UIBaseElement {
95
+ /** the fill behind the children; `null` leaves it transparent */
96
+ fillColor: Paint | null;
97
+ /** drawn around the edge; `null` for none */
98
+ borderColor: Paint | null;
99
+ /** how thick that border is */
100
+ borderWidth: number;
101
+ /** corner radius; `0` is square */
102
+ radius: number;
103
+ /** whether it swallows pointer events aimed at what is behind it */
104
+ blocking: boolean;
105
+ /**
106
+ * How far the panel drifts up and down, in pixels. `0`, the default,
107
+ * leaves it still.
108
+ *
109
+ * The slow float an idle dialogue or pause panel has in a lot of games,
110
+ * which is there so a screen waiting for input does not look frozen. It
111
+ * is a sine, so this is the distance to either extreme and the panel
112
+ * covers twice it over a cycle; 2 to 4 is the usual range, and it starts
113
+ * by rising rather than sinking.
114
+ *
115
+ * Do not go much below 2. The renderer snaps a translation to whole
116
+ * pixels, truncating, so an amplitude of 1 spends most of the cycle
117
+ * reading as 0 and the panel twitches rather than drifts.
118
+ *
119
+ * The panel is CLICKABLE where it is drawn: the offset goes into
120
+ * {@link UIPanel#getAbsolutePosition}, which is what the bounds pipeline
121
+ * reads, so the hit area of the panel and of every widget inside it
122
+ * follows the float at any depth. `pos` is deliberately left alone, so a
123
+ * caller still reads and writes the resting place rather than a value
124
+ * that moves under them.
125
+ *
126
+ * The bounds are rebuilt only on the frames the offset actually changes,
127
+ * so a panel with no bob costs nothing.
128
+ * @default 0
129
+ */
130
+ bobAmplitude: number;
131
+ /**
132
+ * How long one full up and down cycle takes, in milliseconds.
133
+ *
134
+ * Anything at or below zero turns the bob off rather than dividing by it.
135
+ * That is not politeness: the offset would be `NaN`, and one `translate`
136
+ * by `NaN` writes it into the transform, where every batched vertex under
137
+ * it inherits the poison and the GPU clips the lot away. A panel that
138
+ * silently vanished would be a long way from an obviously bad period.
139
+ * @default 2000
140
+ */
141
+ bobPeriod: number;
142
+ /**
143
+ * @param x - position of the panel's left edge
144
+ * @param y - position of the panel's top edge
145
+ * @param settings - see {@link UIPanelSettings}
146
+ */
147
+ constructor(x: number, y: number, settings: UIPanelSettings);
148
+ /**
149
+ * Advance the bob.
150
+ * @param dt - time since the last frame, in milliseconds
151
+ * @returns whether the panel needs redrawing
152
+ */
153
+ update(dt: number): boolean;
154
+ /**
155
+ * Draw the fill, the border, and then the children over both.
156
+ * @param renderer - the renderer to draw with
157
+ * @param viewport - the camera being drawn through, passed to the children
158
+ */
159
+ draw(renderer: Renderer, viewport?: Camera2d): void;
160
+ /**
161
+ * Where the panel IS, bob included.
162
+ *
163
+ * THE hook that makes a floating panel honest. Both bounds paths funnel
164
+ * through this one method, and a child's absolute position is the sum of
165
+ * the chain above it, so adding the offset here reaches the panel's own
166
+ * hit area and every descendant's, at any depth, without any of them
167
+ * knowing a bob exists.
168
+ *
169
+ * Not `currentTransform`, which was the obvious guess: that reaches a
170
+ * renderable's OWN bounds and not its children's, so a bobbing panel's
171
+ * swallow rectangle would drift off the widgets sitting in it. And not a
172
+ * write to `pos`, which would reach everything correctly but silently
173
+ * overwrite a caller's own write on the very next frame.
174
+ *
175
+ * {@link Particle} overrides this method for the same reason, its
176
+ * placement not being in its `pos` chain either.
177
+ * @returns the absolute position, offset by the bob
178
+ */
179
+ getAbsolutePosition(): Vector3d;
180
+ /**
181
+ * The matrix form of the same offset.
182
+ *
183
+ * Without it `getWorldTransform()` and `getAbsolutePosition()` disagree
184
+ * about a bobbing panel, and the contract on those two says that for a
185
+ * `Container` they coincide.
186
+ * @param out - matrix to write into
187
+ * @returns `out`, for chaining
188
+ */
189
+ protected getLocalTransform(out: Matrix3d): Matrix3d;
190
+ /**
191
+ * Resize this panel's bounds, and refresh its children's.
192
+ *
193
+ * `Container` does those two jobs in ONE loop, both gated on
194
+ * `enableChildBoundsUpdate`, and a panel wants exactly one of them. The
195
+ * flag is off here so that a label overhanging the edge cannot grow the
196
+ * rectangle a blocking panel swallows clicks inside, and turning it off
197
+ * took the other job with it: a child's bounds are absolute, worked out
198
+ * once through `getAbsolutePosition()` and then cached, so moving the
199
+ * panel left every child's HIT AREA behind at the old place while the
200
+ * whole panel drew at the new one. A dialog slid or snapped into position
201
+ * after it was built had buttons that only answered where they used to
202
+ * be.
203
+ *
204
+ * This costs nothing per frame: `pos` calls `updateBounds` when it is
205
+ * written, so the walk happens when the panel actually moves.
206
+ * @param absolute - update in world absolute coordinates
207
+ * @returns this panel's bounds
208
+ */
209
+ updateBounds(absolute?: boolean): import("../../index.ts").Bounds;
210
+ /**
211
+ * Consume a click on the panel itself, unless told not to.
212
+ *
213
+ * Returning `false` is how {@link UIBaseElement} consumes. A child is
214
+ * asked before the container holding it, so this only ever sees a click
215
+ * that missed every one of them, which for a dialog means a click on its
216
+ * own background and should go no further.
217
+ * @returns false while {@link UIPanel#blocking}
218
+ */
219
+ onClick(): boolean;
220
+ /**
221
+ * Consume the release that follows a click on the panel, unless told not
222
+ * to.
223
+ *
224
+ * The three handlers consume independently. Taking the press and leaving
225
+ * the release is half a block: the pointer-up still reaches whatever is
226
+ * under the dialog, so a button there completes an interaction it never
227
+ * began.
228
+ * @returns false while {@link UIPanel#blocking}
229
+ */
230
+ onRelease(): boolean;
231
+ /**
232
+ * Consume a hover on the panel itself, unless told not to.
233
+ *
234
+ * Without this a widget UNDER a dialog keeps lighting up as the pointer
235
+ * crosses the panel covering it.
236
+ * @returns false while {@link UIPanel#blocking}
237
+ */
238
+ onOver(): boolean;
239
+ /**
240
+ * Hand back what the painter borrowed.
241
+ * @ignore
242
+ */
243
+ onDestroyEvent(): void;
244
+ }
245
+ //# sourceMappingURL=uipanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uipanel.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/uipanel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACzB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,aAAa;IACjD,iEAAiE;IACjE,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,6CAA6C;IAC7C,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;IAC1B,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,CAAC;IAmClB;;;;OAIG;gBACS,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe;IAiE3D;;;;OAIG;IACM,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAmBpC;;;;OAIG;IACM,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ;IA6CrD;;;;;;;;;;;;;;;;;;OAkBG;IACM,mBAAmB,IAAI,QAAQ;IAMxC;;;;;;;;OAQG;cACgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ;IAS7D;;;;;;;;;;;;;;;;;;OAkBG;IACM,YAAY,CAAC,QAAQ,UAAO;IAQrC;;;;;;;;OAQG;IACM,OAAO,IAAI,OAAO;IAI3B;;;;;;;;;OASG;IACM,SAAS,IAAI,OAAO;IAI7B;;;;;;OAMG;IACM,MAAM,IAAI,OAAO;IAI1B;;;OAGG;IACM,cAAc;CAIvB"}
@@ -1,5 +1,6 @@
1
1
  import type Camera2d from "../../camera/camera2d.ts";
2
2
  import { RoundRect } from "../../geometries/roundrect.ts";
3
+ import type Pointer from "../../input/pointer.ts";
3
4
  import type { Bounds } from "../../physics/bounds.ts";
4
5
  import type Renderer from "../../video/renderer.js";
5
6
  import BitmapText from "../text/bitmaptext.js";
@@ -8,6 +9,7 @@ interface UITextButtonSettings {
8
9
  font?: string;
9
10
  size?: number;
10
11
  text?: string;
12
+ /** see {@link UITextButton.bindKey} */
11
13
  bindKey?: string | number;
12
14
  hoverOffColor?: string;
13
15
  hoverOnColor?: string;
@@ -25,9 +27,31 @@ interface UITextButtonSettings {
25
27
  */
26
28
  export default class UITextButton extends UIBaseElement {
27
29
  /**
28
- * The key to bind the action to
30
+ * Keyboard shortcut: an input.KEY keycode or an existing input action name.
31
+ * A press calls onClick() and its matching release calls onRelease(), both
32
+ * without a pointer event. Shortcuts are active only while the button is
33
+ * activated and never change global key bindings. The first input to press
34
+ * owns the button until released; shortcuts do not start pointer dragging
35
+ * or tap-and-hold.
36
+ *
37
+ * `isClickable` gates the PRESS, not the release: a button disabled while
38
+ * its key is held still releases when that key comes up, so it cannot be
39
+ * left stuck down.
40
+ *
41
+ * **Losing focus or being removed cancels a held press WITHOUT calling
42
+ * `onRelease()`.** The press was abandoned rather than completed, so the
43
+ * button returns to its released state silently. Code that treats the pair
44
+ * as press and depress, firing a weapon on click and stopping on release,
45
+ * needs to stop on {@link event.BLUR} too or it will still be firing when
46
+ * the window comes back.
47
+ * @default -1
29
48
  */
30
49
  bindKey: string | number;
50
+ private keyboardKey;
51
+ private keyboardActive;
52
+ private readonly keyDown;
53
+ private readonly keyUp;
54
+ private readonly cancelKeyboardPress;
31
55
  /**
32
56
  * The css value of a color to be used if the pointer is not hovering over the button
33
57
  */
@@ -95,6 +119,11 @@ export default class UITextButton extends UIBaseElement {
95
119
  * world.addChild(new PlayButton(15,200));
96
120
  */
97
121
  constructor(x: number, y: number, settings: UITextButtonSettings);
122
+ onActivateEvent(): void;
123
+ onDeactivateEvent(): void;
124
+ clicked(event: Pointer): boolean | void;
125
+ release(event: Pointer): boolean | void;
126
+ pointerMove(event: Pointer): void;
98
127
  draw(renderer: Renderer, viewport?: Camera2d): void;
99
128
  }
100
129
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"uitextbutton.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/uitextbutton.ts"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
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/system/bootstrap.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,eAAO,IAAI,WAAW,SAAQ,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,IAAI,SAmDnB"}
@@ -27,6 +27,17 @@ declare const pool: ObjectPool;
27
27
  * which means, that on level loading the engine will try to instantiate every object
28
28
  * found in the map, based on the user defined name in each Object Properties<br>
29
29
  * <img src="../images/object_properties.png"/><br>
30
+ *
31
+ * **Superseded by the typed pools.** `createPool` arrived in 18.0.0 and does
32
+ * the same job without the string keys: `getPool("tween")`, `getPool("text")`
33
+ * and the rest are typed, so a wrong name is a compile error rather than a
34
+ * throw, and a pool can be created for any class with `createPool`. For
35
+ * registering a class so a Tiled map can name it, use
36
+ * {@link registerTiledObjectClass}, which is what this now delegates to.
37
+ *
38
+ * The engine itself no longer uses this pool for anything.
39
+ * @deprecated since 18.0.0, use {@link getPool} / `createPool`, and
40
+ * {@link registerTiledObjectClass} for Tiled classes
30
41
  * @see {@link pool} the default global instance of ObjectPool
31
42
  */
32
43
  declare class ObjectPool {
@@ -106,9 +117,18 @@ declare class ObjectPool {
106
117
  * Object pooling for the object class must be enabled,
107
118
  * and object must have been instantiated using {@link pull},
108
119
  * otherwise this function won't work
109
- * @throws will throw an error if the object cannot be recycled
120
+ *
121
+ * Reports failure by RETURNING FALSE. It used to throw by default, and
122
+ * nothing at the call site made that visible: a class that was never
123
+ * registered, or registered without recycling, aborted whatever was
124
+ * running. Both of the internal uses removed in 20.7.0 failed that way,
125
+ * inside a `destroy()` that had already recycled other state, which left
126
+ * a half-torn-down object to die later somewhere unrelated. Pass
127
+ * `throwOnError` to opt back in where a missed registration is a bug you
128
+ * want to hear about immediately.
110
129
  * @param {object} obj - instance to be recycled
111
- * @param {boolean} [throwOnError=true] - throw an exception if the object cannot be recycled
130
+ * @param {boolean} [throwOnError=false] - throw an exception instead of returning false
131
+ * @throws when the object cannot be recycled AND `throwOnError` is true
112
132
  * @returns {boolean} true if the object was successfully recycled in the object pool
113
133
  */
114
134
  push(obj: object, throwOnError?: boolean): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"legacy_pool.d.ts","sourceRoot":"","sources":["../../src/system/legacy_pool.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,kEAEC;;AAmND;;;;;;;;;;;;;;GAcG;AACH,+BAA8B;AAhO9B;;;;;;;;;;;;GAYG;AACH;IAEE,gBAAqB;IACrB,yBAAyB;IAEzB;;;;;;;;;;;;;;OAcG;IACH,mBARU,OAAO,CAQY;IAG9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAhBW,MAAM,YACN,MAAM,cACN,OAAO,QAsCjB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAnBW,MAAM,WACH,GAAC,EAAA,GACF,MAAM,CAsClB;IAED;;;;OAIG;IACH,cAOC;IAED;;;;;;;;;OASG;IACH,UAJW,MAAM,iBACN,OAAO,GACL,OAAO,CAgBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;OAUG;IACH,cAPW,MAAM,GACJ,OAAO,CAcnB;IAED;;;OAGG;IACH,oBAFa,MAAM,CAIlB;CACD"}
1
+ {"version":3,"file":"legacy_pool.d.ts","sourceRoot":"","sources":["../../src/system/legacy_pool.js"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,kEAEC;;AA4QD;;;;;;;;;;;;;;GAcG;AACH,+BAA8B;AAvP9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAEE,gBAAqB;IACrB,yBAAyB;IAEzB;;;;;;;;;;;;;;OAcG;IACH,mBARU,OAAO,CAQY;IAG9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAhBW,MAAM,YACN,MAAM,cACN,OAAO,QAuCjB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAnBW,MAAM,WACH,GAAC,EAAA,GACF,MAAM,CAuClB;IAED;;;;OAIG;IACH,cAOC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,UALW,MAAM,iBACN,OAAO,GAEL,OAAO,CAiBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;OAUG;IACH,cAPW,MAAM,GACJ,OAAO,CAcnB;IAED;;;OAGG;IACH,oBAFa,MAAM,CAIlB;CACD"}