23 lines
1.2 KiB
JavaScript
23 lines
1.2 KiB
JavaScript
import Phaser from '../js/vendor/phaser.js';
|
|
// Minimal headless-ish game just to get a scene/context.
|
|
const game = new Phaser.Game({ type: Phaser.HEADLESS, width: 100, height: 100,
|
|
scene: { create() { this.__done = true; } } });
|
|
window.__CP__ = null;
|
|
game.events.once('ready', () => {
|
|
const s = game.scene.getScenes(true)[0];
|
|
const out = { steps: [] };
|
|
const mk = () => {
|
|
const c = new Phaser.GameObjects.Container(s, 0, 0);
|
|
const ch = new Phaser.GameObjects.Sprite(s, 0, 0);
|
|
c.add(ch);
|
|
return { c, ch };
|
|
};
|
|
// 1. does destroy() destroy children?
|
|
{ const { c, ch } = mk(); c.destroy(); out.steps.push('destroy() -> child.isDestroyed=' + ch.isDestroyed + ' child.scene=' + (ch.scene === null)); }
|
|
// 2. removeAll(true)
|
|
{ const { c, ch } = mk(); c.removeAll(true); out.steps.push('removeAll(true) -> child.isDestroyed=' + ch.isDestroyed + ' stillInList=' + c.list.includes(ch)); }
|
|
// 3. removeAll(false) then destroy
|
|
{ const { c, ch } = mk(); c.removeAll(false); out.steps.push('removeAll(false) -> child.isDestroyed=' + ch.isDestroyed + ' inList=' + c.list.includes(ch)); c.destroy(); out.steps.push(' then destroy() -> child.isDestroyed=' + ch.isDestroyed); }
|
|
window.__CP__ = out;
|
|
});
|