Use pivots yet again
This commit is contained in:
parent
e583377d45
commit
5091b21833
|
@ -55,11 +55,15 @@ export class SpriteInstance {
|
|||
this.frameCount = this.subset.frames.length
|
||||
this.frame = this.subset.frames[this.frameIndex]
|
||||
let s = new PIXI.Sprite(this.frame.texture)
|
||||
if (this.frame.originX) {
|
||||
if (this.frame.originX !== undefined) {
|
||||
s.pivot.x = this.frame.originX
|
||||
} else {
|
||||
s.pivot.x = s.width / 2
|
||||
}
|
||||
if (this.frame.originY) {
|
||||
if (this.frame.originY !== undefined) {
|
||||
s.pivot.y = this.frame.originY
|
||||
} else {
|
||||
s.pivot.y = s.height / 2
|
||||
}
|
||||
this.container.addChild(s)
|
||||
}
|
||||
|
@ -85,4 +89,17 @@ export class SpriteInstance {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
get width(): number {
|
||||
return this.frame?.width ?? this.container.width
|
||||
}
|
||||
get height(): number {
|
||||
return this.frame?.height ?? this.container.height
|
||||
}
|
||||
get originY(): number {
|
||||
return this.frame?.originY ?? 0
|
||||
}
|
||||
get originX(): number {
|
||||
return this.frame?.originX ?? 0
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user