import {Assets} from "pixi.js";

import Locator from "../services/Locator";
import {Spine} from "pixi-spine";
import {SETTINGS} from "../constants/constants";

export default class SpineScene extends Spine {
  constructor(assetName) {
    super(Assets.get(assetName).spineData);
  }

  get resizeSkinPrefix() {
    return ''
  }

  get resizeSkin() {
    return this.resizeSkinPrefix + Math.floor(Locator.viewport.cropWidthRatio * 10) * 10;
  }

  resize() {
    this.position.set(
      SETTINGS.viewport.width * 0.5,
      SETTINGS.viewport.height * 0.5
    )
    this.skeleton.setSkinByName(this.resizeSkin);
    this.update(0);
  }
}
