@makefully/platypus 4.1.13 → 4.1.15
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/CHANGELOG.md +17 -0
- package/lib/platypus.css +4 -6
- package/lib/platypus.js +1 -1
- package/package.json +1 -1
- package/src/PIXIAnimation.js +6 -0
- package/src/components/EntityContainer.js +62 -17
- package/src/components/RenderSprite.js +7 -2
- package/src/platypus.css +4 -6
package/package.json
CHANGED
package/src/PIXIAnimation.js
CHANGED
|
@@ -339,6 +339,9 @@ const
|
|
|
339
339
|
*/
|
|
340
340
|
stop () {
|
|
341
341
|
this.paused = true;
|
|
342
|
+
if (this._animation?.stop) {
|
|
343
|
+
this._animation.stop();
|
|
344
|
+
}
|
|
342
345
|
};
|
|
343
346
|
|
|
344
347
|
/**
|
|
@@ -348,6 +351,9 @@ const
|
|
|
348
351
|
*/
|
|
349
352
|
play () {
|
|
350
353
|
this.paused = false;
|
|
354
|
+
if (this._animation?.play) {
|
|
355
|
+
this._animation.play();
|
|
356
|
+
}
|
|
351
357
|
};
|
|
352
358
|
|
|
353
359
|
/**
|
|
@@ -187,6 +187,10 @@ const
|
|
|
187
187
|
},
|
|
188
188
|
|
|
189
189
|
addChildEventListeners (entity) {
|
|
190
|
+
if (this._destroyed) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
190
194
|
const
|
|
191
195
|
{_listeners} = entity;
|
|
192
196
|
|
|
@@ -219,33 +223,55 @@ const
|
|
|
219
223
|
},
|
|
220
224
|
|
|
221
225
|
removeChildEventListeners: function (entity) {
|
|
222
|
-
|
|
226
|
+
const
|
|
227
|
+
listener = entity.containerListener;
|
|
228
|
+
|
|
229
|
+
if (!listener) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const
|
|
234
|
+
{events} = listener,
|
|
235
|
+
// Prefer current shape; fall back to legacy `messages`.
|
|
236
|
+
handlers = listener.handlers ?? listener.messages;
|
|
237
|
+
|
|
238
|
+
if (events && handlers) {
|
|
223
239
|
const
|
|
224
|
-
{events, handlers} = entity.containerListener,
|
|
225
240
|
{length} = events;
|
|
226
241
|
|
|
227
242
|
for (let i = 0; i < length; i++) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
const
|
|
244
|
+
handler = handlers[i];
|
|
245
|
+
|
|
246
|
+
if (!handler) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (handler.callback) {
|
|
251
|
+
this.off(events[i], handler.callback, handler.context);
|
|
252
|
+
} else {
|
|
253
|
+
this.off(events[i], handler);
|
|
254
|
+
}
|
|
233
255
|
}
|
|
256
|
+
}
|
|
234
257
|
|
|
258
|
+
if (events) {
|
|
235
259
|
arrayCache.recycle(events);
|
|
236
|
-
arrayCache.recycle(handlers);
|
|
237
|
-
|
|
238
|
-
entity.containerListener.recycle();
|
|
239
|
-
entity.containerListener = null;
|
|
240
260
|
}
|
|
261
|
+
if (listener.handlers) {
|
|
262
|
+
arrayCache.recycle(listener.handlers);
|
|
263
|
+
}
|
|
264
|
+
if (listener.messages) {
|
|
265
|
+
arrayCache.recycle(listener.messages);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
listener.recycle();
|
|
269
|
+
entity.containerListener = null;
|
|
241
270
|
},
|
|
242
271
|
|
|
243
272
|
addChildEventListener: function (entity, event, handler) {
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
"events", arrayCache.setUp(),
|
|
247
|
-
"handlers", arrayCache.setUp()
|
|
248
|
-
);
|
|
273
|
+
if (this._destroyed) {
|
|
274
|
+
return;
|
|
249
275
|
}
|
|
250
276
|
|
|
251
277
|
const
|
|
@@ -258,6 +284,13 @@ const
|
|
|
258
284
|
);
|
|
259
285
|
|
|
260
286
|
if (newHandler) {
|
|
287
|
+
if (!entity.containerListener) {
|
|
288
|
+
entity.containerListener = Data.setUp(
|
|
289
|
+
"events", arrayCache.setUp(),
|
|
290
|
+
"handlers", arrayCache.setUp()
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
261
294
|
entity.containerListener.events.push(event);
|
|
262
295
|
entity.containerListener.handlers.push(newHandler);
|
|
263
296
|
}
|
|
@@ -265,7 +298,19 @@ const
|
|
|
265
298
|
|
|
266
299
|
removeChildEventListener: function (entity, event, callback) {
|
|
267
300
|
const
|
|
268
|
-
|
|
301
|
+
listener = entity.containerListener;
|
|
302
|
+
|
|
303
|
+
if (!listener) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const
|
|
308
|
+
{events, handlers} = listener;
|
|
309
|
+
|
|
310
|
+
if (!events || !handlers) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
269
314
|
let i = events.length;
|
|
270
315
|
|
|
271
316
|
while (i--) {
|
|
@@ -430,15 +430,20 @@ export default createComponentClass(/** @lends platypus.components.RenderSprite.
|
|
|
430
430
|
events: {
|
|
431
431
|
"handle-render": function (renderData) {
|
|
432
432
|
if (this.sprite) {
|
|
433
|
+
const
|
|
434
|
+
playing = !this.sprite.paused;
|
|
435
|
+
|
|
433
436
|
/**
|
|
434
437
|
* This event is triggered each tick to check for animation updates.
|
|
435
438
|
*
|
|
436
439
|
* @event platypus.Entity#update-animation
|
|
437
440
|
* @param playing {Boolean} Whether the animation is in a playing or paused state.
|
|
438
441
|
*/
|
|
439
|
-
this.owner.triggerEvent('update-animation',
|
|
442
|
+
this.owner.triggerEvent('update-animation', playing);
|
|
440
443
|
|
|
441
|
-
|
|
444
|
+
if (playing) {
|
|
445
|
+
this.sprite.update(renderData.delta);
|
|
446
|
+
}
|
|
442
447
|
}
|
|
443
448
|
},
|
|
444
449
|
|
package/src/platypus.css
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
div#captions {
|
|
2
|
-
user-select: none;
|
|
3
|
-
-moz-user-select: none;
|
|
4
2
|
-webkit-user-select: none;
|
|
5
|
-
|
|
3
|
+
user-select: none;
|
|
6
4
|
-webkit-touch-callout: none;
|
|
7
5
|
}
|
|
8
6
|
|
|
@@ -11,11 +9,10 @@ canvas.platypus-canvas {
|
|
|
11
9
|
position: relative;
|
|
12
10
|
width: 100%;
|
|
13
11
|
|
|
14
|
-
user-select: none;
|
|
15
|
-
-moz-user-select: none;
|
|
16
12
|
-webkit-user-select: none;
|
|
17
|
-
|
|
13
|
+
user-select: none;
|
|
18
14
|
-webkit-touch-callout: none;
|
|
15
|
+
touch-action: none;
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
.platypus-debugging {
|
|
@@ -28,6 +25,7 @@ canvas.platypus-canvas {
|
|
|
28
25
|
z-index: 2;
|
|
29
26
|
font-family: "Lucida Console", Monaco, monospace;
|
|
30
27
|
-webkit-touch-callout: none;
|
|
28
|
+
-webkit-user-select: none;
|
|
31
29
|
user-select: none;
|
|
32
30
|
cursor: default;
|
|
33
31
|
margin: 0;
|