@makefully/platypus 4.1.5 → 4.1.8

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 (136) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -3
  3. package/lib/platypus.js +1 -1
  4. package/package.json +7 -6
  5. package/src/AABB.js +685 -0
  6. package/src/ActionState.js +121 -0
  7. package/src/AssetManager.js +206 -0
  8. package/src/CollisionData.js +96 -0
  9. package/src/CollisionDataContainer.js +127 -0
  10. package/src/CollisionShape.js +315 -0
  11. package/src/Component.js +231 -0
  12. package/src/Data.js +64 -0
  13. package/src/DataMap.js +204 -0
  14. package/src/Entity.js +404 -0
  15. package/src/EntityLinker.js +113 -0
  16. package/src/EventHandler.js +115 -0
  17. package/src/EventHandlerList.js +251 -0
  18. package/src/Game.js +840 -0
  19. package/src/Gamepad.js +175 -0
  20. package/src/ID3CaptionPlayer.js +61 -0
  21. package/src/Messenger.js +365 -0
  22. package/src/PIXIAnimation.js +622 -0
  23. package/src/RandomSet.js +140 -0
  24. package/src/SFXPlayer.js +120 -0
  25. package/src/StateMap.js +252 -0
  26. package/src/Storage.js +152 -0
  27. package/src/TickerClient.js +48 -0
  28. package/src/TickerServer.js +23 -0
  29. package/src/TimeEvent.js +50 -0
  30. package/src/TimeEventList.js +100 -0
  31. package/src/VOPlayer.js +684 -0
  32. package/src/Vector.js +702 -0
  33. package/src/components/AIChaser.js +161 -0
  34. package/src/components/AIPacer.js +107 -0
  35. package/src/components/AudioMusic.js +151 -0
  36. package/src/components/AudioSFX.js +673 -0
  37. package/src/components/AudioVO.js +301 -0
  38. package/src/components/CollisionBasic.js +826 -0
  39. package/src/components/CollisionFilter.js +74 -0
  40. package/src/components/CollisionGroup.js +448 -0
  41. package/src/components/CollisionTiles.js +608 -0
  42. package/src/components/ComponentSwitcher.js +173 -0
  43. package/src/components/ControllerInput.js +65 -0
  44. package/src/components/Counter.js +165 -0
  45. package/src/components/EntityCamera.js +215 -0
  46. package/src/components/EntityContainer.js +549 -0
  47. package/src/components/EntityController.js +541 -0
  48. package/src/components/HandlerCamera.js +1052 -0
  49. package/src/components/HandlerCollision.js +1318 -0
  50. package/src/components/HandlerController.js +291 -0
  51. package/src/components/HandlerLogic.js +394 -0
  52. package/src/components/HandlerRender.js +217 -0
  53. package/src/components/Interactive.js +502 -0
  54. package/src/components/LevelBuilder.js +524 -0
  55. package/src/components/LogicAngularMovement.js +154 -0
  56. package/src/components/LogicAttachment.js +265 -0
  57. package/src/components/LogicButton.js +466 -0
  58. package/src/components/LogicCarrier.js +39 -0
  59. package/src/components/LogicDestroyMe.js +58 -0
  60. package/src/components/LogicDirectionalMovement.js +325 -0
  61. package/src/components/LogicDragDrop.js +371 -0
  62. package/src/components/LogicImpactLaunch.js +144 -0
  63. package/src/components/LogicPacingPlatform.js +64 -0
  64. package/src/components/LogicPortable.js +112 -0
  65. package/src/components/LogicPortal.js +115 -0
  66. package/src/components/LogicPushable.js +98 -0
  67. package/src/components/LogicRebounder.js +136 -0
  68. package/src/components/LogicRegionSpawner.js +139 -0
  69. package/src/components/LogicRotationalMovement.js +205 -0
  70. package/src/components/LogicSpawner.js +159 -0
  71. package/src/components/LogicStateMachine.js +382 -0
  72. package/src/components/LogicSwitch.js +77 -0
  73. package/src/components/LogicTeleportee.js +68 -0
  74. package/src/components/LogicTeleporter.js +93 -0
  75. package/src/components/LogicTimer.js +178 -0
  76. package/src/components/LogicWindUpRacer.js +179 -0
  77. package/src/components/Motion.js +371 -0
  78. package/src/components/Mover.js +566 -0
  79. package/src/components/Node.js +289 -0
  80. package/src/components/NodeMap.js +295 -0
  81. package/src/components/NodeResident.js +636 -0
  82. package/src/components/Orientation.js +697 -0
  83. package/src/components/RandomEvents.js +73 -0
  84. package/src/components/RelativePosition.js +204 -0
  85. package/src/components/RelayFamily.js +106 -0
  86. package/src/components/RelayGame.js +53 -0
  87. package/src/components/RelayLinker.js +94 -0
  88. package/src/components/RelayParent.js +57 -0
  89. package/src/components/RelaySelf.js +55 -0
  90. package/src/components/Render.js +178 -0
  91. package/src/components/RenderAnimator.js +275 -0
  92. package/src/components/RenderContainer.js +646 -0
  93. package/src/components/RenderDebug.js +319 -0
  94. package/src/components/RenderDestroyMe.js +59 -0
  95. package/src/components/RenderLottie.js +149 -0
  96. package/src/components/RenderProgress.js +120 -0
  97. package/src/components/RenderSpine.js +840 -0
  98. package/src/components/RenderSprite.js +527 -0
  99. package/src/components/RenderText.js +147 -0
  100. package/src/components/RenderTiles.js +1440 -0
  101. package/src/components/SceneChanger.js +128 -0
  102. package/src/components/TiledLoader.js +1459 -0
  103. package/src/components/Timeline.js +314 -0
  104. package/src/components/Tutorial.js +267 -0
  105. package/src/components/Tween.js +296 -0
  106. package/src/components/VoiceOver.js +373 -0
  107. package/src/components/XHR.js +129 -0
  108. package/src/components/index.js +79 -0
  109. package/src/factory.js +305 -0
  110. package/src/index.js +159 -0
  111. package/src/mixins/PIXI.Graphics.js +41 -0
  112. package/src/platypus.css +68 -0
  113. package/src/sayHello.js +50 -0
  114. package/src/shapes/Capsule.js +74 -0
  115. package/src/shapes/Circle.js +43 -0
  116. package/src/shapes/Ellipse.js +117 -0
  117. package/src/shapes/Point.js +191 -0
  118. package/src/shapes/Polygon.js +112 -0
  119. package/src/shapes/Polyline.js +97 -0
  120. package/src/shapes/Rectangle.js +78 -0
  121. package/src/shapes/RoundedRectangle.js +33 -0
  122. package/src/shapes/Segment.js +346 -0
  123. package/src/shapes/adjustedXY.js +19 -0
  124. package/src/shapes/castFromBox2D.js +92 -0
  125. package/src/shapes/castFromObject.js +53 -0
  126. package/src/shapes/castFromPixiGraphics.js +6 -0
  127. package/src/shapes/castFromPixiShape.js +89 -0
  128. package/src/shapes/castToBox2D.js +190 -0
  129. package/src/shapes/castToPixiGraphics.js +100 -0
  130. package/src/shapes/castToPixiShape.js +61 -0
  131. package/src/shapes/checkPointsMap.js +313 -0
  132. package/src/shapes/index.js +35 -0
  133. package/src/utils/array.js +73 -0
  134. package/src/utils/string.js +39 -0
  135. package/lib/243.platypus.mjs +0 -1
  136. package/lib/platypus.mjs +0 -1
@@ -0,0 +1,502 @@
1
+ import Data from '../Data.js';
2
+ import createComponentClass from '../factory.js';
3
+ import {arrayCache} from '../utils/array.js';
4
+ import {shapeFromObject, shapeToPixiShape} from '../shapes/index.js';
5
+
6
+ const
7
+ savedHitAreas = {}; //So generated hitAreas are reused across identical entities.
8
+
9
+ export default createComponentClass(/** @lends platypus.components.Interactive.prototype */{
10
+ id: 'Interactive',
11
+
12
+ properties: {
13
+ /**
14
+ * Sets the container that represents the interactive area.
15
+ *
16
+ * @property container
17
+ * @type PIXI.Container
18
+ * @default null
19
+ */
20
+ "container": null,
21
+
22
+ /**
23
+ * Sets the hit area for interactive responses by describing the dimensions of a clickable rectangle:
24
+ *
25
+ * "hitArea": {
26
+ * "x": 10,
27
+ * "y": 10,
28
+ * "width": 40,
29
+ * "height": 40
30
+ * }
31
+ *
32
+ * Or a circle:
33
+ *
34
+ * "hitArea": {
35
+ * "x": 10,
36
+ * "y": 10,
37
+ * "radius": 40
38
+ * }
39
+ *
40
+ * Or use an array of numbers to define a polygon: [x1, y1, x2, y2, ...]
41
+ *
42
+ * "hitArea": [-10, -10, 30, -10, 30, 30, -5, 30]
43
+ *
44
+ * Defaults to the container if not specified.
45
+ *
46
+ * @property hitArea
47
+ * @type Object
48
+ * @default null
49
+ */
50
+ "hitArea": null,
51
+
52
+ /**
53
+ * Sets whether the entity should respond to mouse hovering.
54
+ *
55
+ * @property hover
56
+ * @type Boolean
57
+ * @default false
58
+ */
59
+ "hover": false,
60
+
61
+ /**
62
+ * Used when returning world coordinates. Typically coordinates are relative to the parent, but when this component is added to the layer level, coordinates must be relative to self.
63
+ *
64
+ * @property relativeToSelf
65
+ * @type String
66
+ * @default false
67
+ */
68
+ "relativeToSelf": false,
69
+
70
+ /**
71
+ * Whether camera updates should trigger "pointermove" and "pressmove" events.
72
+ *
73
+ * @property trackCameraUpdates
74
+ * @type Boolean
75
+ * @default false
76
+ */
77
+ "trackCameraUpdates": false
78
+ },
79
+
80
+ publicProperties: {
81
+ /**
82
+ * Determines whether hovering over the sprite should alter the cursor.
83
+ *
84
+ * @property buttonMode
85
+ * @type Boolean
86
+ * @default false
87
+ * @deprecated
88
+ */
89
+ buttonMode: false
90
+ },
91
+
92
+ /**
93
+ * This component accepts touches and clicks on the entity. It is typically automatically added by a render component that requires interactive functionality.
94
+ *
95
+ * @memberof platypus.components
96
+ * @uses platypus.Component
97
+ * @constructs
98
+ * @listens platypus.Entity#dispatch-event
99
+ * @listens platypus.Entity#handle-render
100
+ * @listens platypus.Entity#input-off
101
+ * @listens platypus.Entity#input-on
102
+ * @listens platypus.Entity#set-hit-area
103
+ * @fires platypus.Entity#pressmove
104
+ * @fires platypus.Entity#pressup
105
+ * @fires platypus.Entity#pointerdown
106
+ * @fires platypus.Entity#pointermove
107
+ * @fires platypus.Entity#pointertap
108
+ * @fires platypus.Entity#pointerout
109
+ * @fires platypus.Entity#pointerover
110
+ * @fires platypus.Entity#pointerup
111
+ * @fires platypus.Entity#pointerupoutside
112
+ * @fires platypus.Entity#pointercancel
113
+ */
114
+ initialize: function () {
115
+ this.pressed = null;
116
+ if (this.hitArea) {
117
+ this.container.hitArea = this.setHitArea(this.hitArea);
118
+ }
119
+
120
+ if (this.buttonMode) {
121
+ platypus.debug.warn('Interactive: "buttonMode" is deprecated. Set "cursor" to "pointer" on the entity instead.');
122
+ }
123
+
124
+ this.dragOver = false;
125
+ },
126
+
127
+ events: {
128
+ /**
129
+ * This event dispatches a PIXI.Event on this component's PIXI.Sprite. Useful for rerouting mouse/keyboard events.
130
+ *
131
+ * @event platypus.Entity#dispatch-event
132
+ * @param event {Object | PIXI.Event} The event to dispatch.
133
+ */
134
+ "dispatch-event": function (event) {
135
+ this.sprite.dispatchEvent(this.sprite, event.event, event.data);
136
+ },
137
+
138
+ 'camera-update': function () {
139
+ if (this.dragOver) {
140
+ this.dragOver();
141
+ }
142
+ },
143
+
144
+ "input-on": function () {
145
+ if (!this.removeInputListeners) {
146
+ this.addInputs();
147
+ }
148
+ },
149
+
150
+ "input-off": function () {
151
+ if (this.removeInputListeners) {
152
+ // Make sure currently-pressed is released.
153
+ if (this.pressed) {
154
+ this.handlePressUp(this.pressed);
155
+ }
156
+ this.removeInputListeners();
157
+ }
158
+ },
159
+
160
+ "pointerdown": function (event) {
161
+ if (this.pressed === null) { // so extra multi-touch presses won't trigger 'pressmove' / 'pressup'
162
+ this.pressed = Data.setUp(event);
163
+ }
164
+ },
165
+
166
+ "pointermove": function (event) {
167
+ if (this.pressed?.pixiEvent?.pointerId === event.pixiEvent.pointerId) {
168
+ /**
169
+ * This event is triggered on press move (drag).
170
+ *
171
+ * @event platypus.Entity#pressmove
172
+ * @param event {DOMEvent} The original DOM pointer event.
173
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
174
+ * @param x {Number} The x coordinate in world units.
175
+ * @param y {Number} The y coordinate in world units.
176
+ * @param entity {platypus.Entity} The entity receiving this event.
177
+ */
178
+ this.owner.triggerEvent('pressmove', event);
179
+ this.pressed.recycle();
180
+ this.pressed = Data.setUp(event);
181
+ }
182
+ },
183
+
184
+ "pointerup": function (event) {
185
+ this.handlePressUp(event);
186
+ },
187
+
188
+ "pointerupoutside": function (event) {
189
+ this.handlePressUp(event);
190
+ },
191
+
192
+ "pointercancel": function (event) {
193
+ this.handlePressUp(event);
194
+ },
195
+
196
+ /**
197
+ * Sets the hit area for interactive responses by describing the dimensions of a clickable rectangle:
198
+ *
199
+ * "hitArea": {
200
+ * "x": 10,
201
+ * "y": 10,
202
+ * "width": 40,
203
+ * "height": 40
204
+ * }
205
+ *
206
+ * Or a circle:
207
+ *
208
+ * "hitArea": {
209
+ * "x": 10,
210
+ * "y": 10,
211
+ * "radius": 40
212
+ * }
213
+ *
214
+ * Or use an array of numbers to define a polygon: [x1, y1, x2, y2, ...]
215
+ *
216
+ * "hitArea": [-10, -10, 30, -10, 30, 30, -5, 30]
217
+ *
218
+ * Defaults to the container if set to `null`.
219
+ *
220
+ * @event platypus.Entity#set-hit-area
221
+ * @param {Object} shape
222
+ */
223
+ "set-hit-area": function (shape) {
224
+ this.container.hitArea = this.setHitArea(shape);
225
+ }
226
+ },
227
+
228
+ methods: {
229
+ addInputs () {
230
+ const
231
+ sprite = this.container,
232
+ removals = arrayCache.setUp(),
233
+ addListener = (event, handler) => {
234
+ sprite.addListener(event, handler);
235
+ removals.push(() => {
236
+ sprite.removeListener(event, handler);
237
+ });
238
+ },
239
+ trigger = (target, eventName, event) => {
240
+ const
241
+ {container} = target;
242
+
243
+ if (
244
+ container && //TML - This is in case we do a scene change using an event and the container is destroyed.
245
+ event.data.originalEvent // This is a workaround for a bug in Pixi 3 where phantom hover events are triggered. - DDD 7/20/16
246
+ ) {
247
+
248
+ container.getBounds(); //TML 1/19/24 - Temporary solution for when container transform scale values were unset for a frame. getBounds() calls _recursivePostUpdateTransform() internally which ensures that the transform is up-to-date for this call.
249
+ const
250
+ {owner, relativeToSelf} = target,
251
+ camera = owner.worldCamera?.viewport ?? owner.parent.worldCamera.viewport,
252
+ matrix = relativeToSelf ? container.worldTransform : container.parent.worldTransform,
253
+ msg = Data.setUp(
254
+ "event", event.data.originalEvent,
255
+ "pixiEvent", event,
256
+ "x", event.data.global.x / matrix.a + camera.left,
257
+ "y", event.data.global.y / matrix.d + camera.top,
258
+ "entity", owner
259
+ );
260
+
261
+ owner.trigger(eventName, msg);
262
+ msg.recycle();
263
+ }
264
+ };
265
+
266
+ // The following appends necessary information to displayed objects to allow them to receive touches and clicks
267
+ sprite.eventMode = 'static';
268
+
269
+ addListener('pointerdown', (event) => {
270
+ /**
271
+ * This event is triggered on pointer down.
272
+ *
273
+ * @event platypus.Entity#pointerdown
274
+ * @param event {DOMEvent} The original DOM pointer event.
275
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
276
+ * @param x {Number} The x coordinate in world units.
277
+ * @param y {Number} The y coordinate in world units.
278
+ * @param entity {platypus.Entity} The entity receiving this event.
279
+ */
280
+ trigger(this, 'pointerdown', event);
281
+ event.currentTarget.mouseTarget = true;
282
+ });
283
+ addListener('pointerup', (event) => {
284
+ /**
285
+ * This event is triggered on pointer up.
286
+ *
287
+ * @event platypus.Entity#pointerup
288
+ * @param event {DOMEvent} The original DOM pointer event.
289
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
290
+ * @param x {Number} The x coordinate in world units.
291
+ * @param y {Number} The y coordinate in world units.
292
+ * @param entity {platypus.Entity} The entity receiving this event.
293
+ */
294
+ trigger(this, 'pointerup', event);
295
+ event.currentTarget.mouseTarget = false;
296
+
297
+ if (event.currentTarget.removeDisplayObject) {
298
+ event.currentTarget.removeDisplayObject();
299
+ }
300
+ });
301
+ addListener('pointerupoutside', (event) => {
302
+ /**
303
+ * This event is triggered on pointer up outside.
304
+ *
305
+ * @event platypus.Entity#pointerupoutside
306
+ * @param event {DOMEvent} The original DOM pointer event.
307
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
308
+ * @param x {Number} The x coordinate in world units.
309
+ * @param y {Number} The y coordinate in world units.
310
+ * @param entity {platypus.Entity} The entity receiving this event.
311
+ */
312
+ trigger(this, 'pointerupoutside', event);
313
+ event.currentTarget.mouseTarget = false;
314
+
315
+ if (event.currentTarget.removeDisplayObject) {
316
+ event.currentTarget.removeDisplayObject();
317
+ }
318
+ });
319
+ addListener('pointercancel', (event) => {
320
+ /**
321
+ * This event is triggered on pointer cancel.
322
+ *
323
+ * @event platypus.Entity#pointercancel
324
+ * @param event {DOMEvent} The original DOM pointer event.
325
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
326
+ * @param x {Number} The x coordinate in world units.
327
+ * @param y {Number} The y coordinate in world units.
328
+ * @param entity {platypus.Entity} The entity receiving this event.
329
+ */
330
+ trigger(this, 'pointercancel', event);
331
+ event.currentTarget.mouseTarget = false;
332
+
333
+ if (event.currentTarget.removeDisplayObject) {
334
+ event.currentTarget.removeDisplayObject();
335
+ }
336
+ });
337
+ addListener('pointermove', (event) => {
338
+ /**
339
+ * This event is triggered on pointer move.
340
+ *
341
+ * @event platypus.Entity#pointermove
342
+ * @param event {DOMEvent} The original DOM pointer event.
343
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
344
+ * @param x {Number} The x coordinate in world units.
345
+ * @param y {Number} The y coordinate in world units.
346
+ * @param entity {platypus.Entity} The entity receiving this event.
347
+ */
348
+ trigger(this, 'pointermove', event);
349
+ event.currentTarget.mouseTarget = true;
350
+ });
351
+ addListener('pointertap', (event) => {
352
+ /**
353
+ * This event is triggered on pointer tap.
354
+ *
355
+ * @event platypus.Entity#pointertap
356
+ * @param event {DOMEvent} The original DOM pointer event.
357
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
358
+ * @param x {Number} The x coordinate in world units.
359
+ * @param y {Number} The y coordinate in world units.
360
+ * @param entity {platypus.Entity} The entity receiving this event.
361
+ */
362
+ trigger(this, 'pointertap', event);
363
+ });
364
+
365
+ if (this.hover) {
366
+ addListener('pointerover', (event) => {
367
+ /**
368
+ * This event is triggered on pointer over.
369
+ *
370
+ * @event platypus.Entity#pointerover
371
+ * @param event {DOMEvent} The original DOM pointer event.
372
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
373
+ * @param x {Number} The x coordinate in world units.
374
+ * @param y {Number} The y coordinate in world units.
375
+ * @param entity {platypus.Entity} The entity receiving this event.
376
+ */
377
+ trigger(this, 'pointerover', event);
378
+ });
379
+ addListener('pointerout', (event) => {
380
+ /**
381
+ * This event is triggered on pointer out.
382
+ *
383
+ * @event platypus.Entity#pointerout
384
+ * @param event {DOMEvent} The original DOM pointer event.
385
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
386
+ * @param x {Number} The x coordinate in world units.
387
+ * @param y {Number} The y coordinate in world units.
388
+ * @param entity {platypus.Entity} The entity receiving this event.
389
+ */
390
+ trigger(this, 'pointerout', event);
391
+ });
392
+ }
393
+
394
+ if (this.trackCameraUpdates) {
395
+ const
396
+ handlePositionUpdate = (event) => {
397
+ if (over) {
398
+ over = event;
399
+ }
400
+ };
401
+ let over = null;
402
+
403
+ this.dragOver = () => {
404
+ if (over) {
405
+ trigger(this, 'pointermove', over);
406
+ }
407
+ };
408
+
409
+ addListener('pointerover', (event) => over = event);
410
+ addListener('pointerdown', handlePositionUpdate);
411
+ addListener('pointermove', handlePositionUpdate);
412
+ addListener('pointerout', () => over = null);
413
+
414
+ removals.push(() => {
415
+ over = null;
416
+ this.dragOver = null;
417
+ });
418
+ }
419
+
420
+ this.removeInputListeners = () => {
421
+ for (let i = 0; i < removals.length; i++) {
422
+ removals[i]();
423
+ }
424
+ arrayCache.recycle(removals);
425
+ sprite.eventMode = 'auto';
426
+ this.removeInputListeners = null;
427
+ };
428
+ },
429
+
430
+ setHitArea (shape) {
431
+ if (shape) {
432
+ let sav = '',
433
+ ha = null;
434
+
435
+ try {
436
+ sav = JSON.stringify(shape);
437
+ ha = savedHitAreas[sav];
438
+ } catch (e) {}
439
+
440
+ if (!ha) {
441
+ const
442
+ definition = Array.isArray(shape) ? {
443
+ type: 'polygon',
444
+ points: shape
445
+ } : shape;
446
+
447
+ ha = shapeToPixiShape(shapeFromObject(definition));
448
+
449
+ if (sav) { // can't save if we don't have a valid id
450
+ savedHitAreas[sav] = ha;
451
+ }
452
+ }
453
+
454
+ return ha;
455
+ } else {
456
+ return null;
457
+ }
458
+ },
459
+
460
+ handlePressUp (event) {
461
+ if (this.pressed?.pixiEvent?.pointerId === event.pixiEvent.pointerId) {
462
+ /**
463
+ * This event is triggered on press up.
464
+ *
465
+ * @event platypus.Entity#pressup
466
+ * @param event {DOMEvent} The original DOM pointer event.
467
+ * @param pixiEvent {PIXI.interaction.InteractionEvent} The Pixi pointer event.
468
+ * @param x {Number} The x coordinate in world units.
469
+ * @param y {Number} The y coordinate in world units.
470
+ * @param entity {platypus.Entity} The entity receiving this event.
471
+ */
472
+ this.owner.triggerEvent('pressup', event);
473
+ this.pressed.recycle();
474
+ this.pressed = null;
475
+ }
476
+ },
477
+
478
+ toJSON () { // This component is added by another component, so it shouldn't be returned for reconstruction.
479
+ return null;
480
+ },
481
+
482
+ destroy () {
483
+ const
484
+ {container, removeInputListeners} = this;
485
+
486
+ if (removeInputListeners) {
487
+ removeInputListeners();
488
+ }
489
+
490
+ // This handles removal after the mouseup event to prevent weird input behaviors. If it's not currently a mouse target, we let the render component handle its removal from the parent container.
491
+ if (container.mouseTarget && container.parent) {
492
+ container.visible = false;
493
+ container.removeDisplayObject = () => {
494
+ if (container.parent) {
495
+ container.parent.removeChild(container);
496
+ }
497
+ this.container = null;
498
+ };
499
+ }
500
+ }
501
+ }
502
+ });