[ts] Player, if config.success set an animation but not a viewport, set a viewport.

This commit is contained in:
Nathan Sweet 2021-06-20 13:44:04 -04:00
parent 99f8cba35f
commit cae8b6036e

View File

@ -454,7 +454,8 @@ module spine {
if (config.success) config.success(this); if (config.success) config.success(this);
if (!this.animationState.getCurrent(0)) { let entry = this.animationState.getCurrent(0);
if (!entry) {
if (this.config.animation) if (this.config.animation)
this.setAnimation(this.config.animation); this.setAnimation(this.config.animation);
else { else {
@ -462,7 +463,8 @@ module spine {
entry.trackEnd = 100000000; entry.trackEnd = 100000000;
this.setViewport(entry.animation); this.setViewport(entry.animation);
} }
} } else if (!this.currentViewport)
this.setViewport(entry.animation);
} }
private setupInput () { private setupInput () {
@ -728,8 +730,9 @@ module spine {
height: this.currentViewport.height + (this.currentViewport.padBottom as number) + (this.currentViewport.padTop as number) height: this.currentViewport.height + (this.currentViewport.padBottom as number) + (this.currentViewport.padTop as number)
}; };
if (this.previousViewport) {
let transitionAlpha = ((performance.now() - this.viewportTransitionStart) / 1000) / config.viewport.transitionTime; let transitionAlpha = ((performance.now() - this.viewportTransitionStart) / 1000) / config.viewport.transitionTime;
if (this.previousViewport && transitionAlpha < 1) { if (transitionAlpha < 1) {
let oldViewport = { let oldViewport = {
x: this.previousViewport.x - (this.previousViewport.padLeft as number), x: this.previousViewport.x - (this.previousViewport.padLeft as number),
y: this.previousViewport.y - (this.previousViewport.padBottom as number), y: this.previousViewport.y - (this.previousViewport.padBottom as number),
@ -743,6 +746,7 @@ module spine {
height: oldViewport.height + (viewport.height - oldViewport.height) * transitionAlpha height: oldViewport.height + (viewport.height - oldViewport.height) * transitionAlpha
}; };
} }
}
let viewportSize = this.scale(viewport.width, viewport.height, this.canvas.width, this.canvas.height); let viewportSize = this.scale(viewport.width, viewport.height, this.canvas.width, this.canvas.height);