Allow changing sprite ctor

This commit is contained in:
Ketchetwahmeegwun T. Southall 2022-01-29 17:05:42 -08:00
parent 79e5509cc5
commit 5a47ac00e8

View File

@ -10,19 +10,26 @@ for (let [key, value] of Object.entries(assets)) {
export class SpriteInstance {
container: PIXI.Container
sprite: Sprite
sprite: Sprite|null = null
spriteKey: string = ''
animation?: SpritePart
animationKey: string
animationKey: string = ''
set?: SpritePart
setKey: string
setKey: string = ''
subset?: SpritePart
subsetKey: string
subsetKey: string = ''
frame?: SpritePart
frameIndex: number
frameIndex: number = 0
constructor(ctor: string) {
this.container = new PIXI.Container()
this.setCtor(ctor)
}
setCtor(ctor: string) {
this.container.removeChildren()
let [spriteKey, animationKey, setKey, subsetKey, frameKey] = ctor.split('.')
this.spriteKey = spriteKey
this.animationKey = animationKey
this.setKey = setKey
this.subsetKey = subsetKey