Allow changing sprite ctor
This commit is contained in:
parent
79e5509cc5
commit
5a47ac00e8
|
@ -10,19 +10,26 @@ for (let [key, value] of Object.entries(assets)) {
|
||||||
|
|
||||||
export class SpriteInstance {
|
export class SpriteInstance {
|
||||||
container: PIXI.Container
|
container: PIXI.Container
|
||||||
sprite: Sprite
|
sprite: Sprite|null = null
|
||||||
|
spriteKey: string = ''
|
||||||
animation?: SpritePart
|
animation?: SpritePart
|
||||||
animationKey: string
|
animationKey: string = ''
|
||||||
set?: SpritePart
|
set?: SpritePart
|
||||||
setKey: string
|
setKey: string = ''
|
||||||
subset?: SpritePart
|
subset?: SpritePart
|
||||||
subsetKey: string
|
subsetKey: string = ''
|
||||||
frame?: SpritePart
|
frame?: SpritePart
|
||||||
frameIndex: number
|
frameIndex: number = 0
|
||||||
|
|
||||||
constructor(ctor: string) {
|
constructor(ctor: string) {
|
||||||
this.container = new PIXI.Container()
|
this.container = new PIXI.Container()
|
||||||
|
this.setCtor(ctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
setCtor(ctor: string) {
|
||||||
|
this.container.removeChildren()
|
||||||
let [spriteKey, animationKey, setKey, subsetKey, frameKey] = ctor.split('.')
|
let [spriteKey, animationKey, setKey, subsetKey, frameKey] = ctor.split('.')
|
||||||
|
this.spriteKey = spriteKey
|
||||||
this.animationKey = animationKey
|
this.animationKey = animationKey
|
||||||
this.setKey = setKey
|
this.setKey = setKey
|
||||||
this.subsetKey = subsetKey
|
this.subsetKey = subsetKey
|
||||||
|
|
Loading…
Reference in New Issue
Block a user