P.checkSpriteFrame = function () {
const asset = this.asset;
if (asset && asset.type === T_SPRITE && asset.manifest) {
const copyArray = this.copyArray;
if (this.spriteIsRunning) {
const last = this.spriteLastFrameChange,
choke = this.spriteFrameDuration,
now = _now();
if (now > last + choke) {
const manifest = asset.manifest;
if (manifest) {
const track = manifest[this.spriteTrack],
len = track.length,
loop = this.spriteWillLoop;
let frame = this.spriteCurrentFrame;
frame = (this.spriteForward) ? frame + 1 : frame - 1;
if (frame < 0) frame = (loop) ? len - 1 : 0;
if (frame >= len) frame = (loop) ? 0 : len - 1;
const [source, x, y, w, h] = track[frame];
copyArray.length = 0;
copyArray.push(x, y, w, h);
this.dirtyCopyStart = false;
this.dirtyCopyDimensions = false;
const sourceName = this.source.id || this.source.name;
if (source !== sourceName) {
const newSource = asset.sourceHold[source];
if (newSource) this.source = newSource;
}
this.spriteCurrentFrame = frame;
this.spriteLastFrameChange = now;
}
}
}
else {
const [, x, y, w, h] = asset.manifest[this.spriteTrack][this.spriteCurrentFrame],
[cx, cy, cw, ch] = copyArray;
if (cx !== x || cy !== y || cw !== w || ch !== h) {
copyArray.length = 0;
copyArray.push(x, y, w, h);
this.dirtyCopyStart = false;
this.dirtyCopyDimensions = false;
}
}
}
};