import * as PIXI from 'pixi.js';
const app = new PIXI.Application({ background: '#1099bb', resizeTo: window });
document.body.appendChild(app.view);
PIXI.Assets.add('flowerTop', 'https://pixijs.com/assets/flowerTop.png');
PIXI.Assets.add('eggHead', 'https://pixijs.com/assets/eggHead.png');
PIXI.Assets.backgroundLoad(['flowerTop', 'eggHead']);
PIXI.Assets.load('eggHead').then((texture) =>
{
let isEggHead = true;
const character = new PIXI.Sprite(texture);
character.anchor.set(0.5);
character.x = app.screen.width / 2;
character.y = app.screen.height / 2;
character.eventMode = 'static';
character.cursor = 'pointer';
app.stage.addChild(character);
character.on('pointertap', async () =>
{
isEggHead = !isEggHead;
character.texture = await PIXI.Assets.load(isEggHead ? 'eggHead' : 'flowerTop');
});
});