I try to import 'pixi-spine' plugin to my file where I imported PIXI lib. But I can't do it. I use webpack to package files. I try another variants to do it, but I have this error
import * as PIXI from 'pixi.js';
import {Spine} from 'pixi-spine';
import * as spineJSON1 from '../../../../../src/theme/assets/spine/ship_1_col_1.json';
export function newAnimations() {
const app = new PIXI.Application();
document.body.appendChild(app.view);
// load spine data
app.loader
.add('ship_1_col_1', spineJSON1)
// .add('ship_1_col_1', 'src/theme/assets/spine/ship_1_col_1.json')
.load(onAssetsLoaded);
app.stage.interactive = true;
app.stage.buttonMode = true;
function onAssetsLoaded(loader, res) {
const ship_1_col_1 = new PIXI.spine.Spine(res.ship_1_col_1.spineData);
// set current skin
ship_1_col_1.skeleton.setSkinByName('ship_1_col_1');
ship_1_col_1.skeleton.setSlotsToSetupPose();
// set the position
ship_1_col_1.x = 400;
ship_1_col_1.y = 600;
ship_1_col_1.scale.set(1.5);
// play animation
ship_1_col_1.state.setAnimation(0, 'idle', true);
app.stage.addChild(ship_1_col_1);
app.stage.on('pointertap', () => {
// change current skin
const currentSkinName = goblin.skeleton.skin.name;
const newSkinName = (currentSkinName === 'goblin' ? 'goblingirl' : 'goblin');
ship_1_col_1.skeleton.setSkinByName(newSkinName);
ship_1_col_1.skeleton.setSlotsToSetupPose();
});
}
}
But I have error from 'pixi-spine' - PIXI is not defined