Selaa lähdekoodia

fixes #1450

tags/v0.6^2
Shaun 4 vuotta sitten
vanhempi
commit
0b270151ff
1 muutettua tiedostoa jossa 26 lisäystä ja 6 poistoa
  1. +26
    -6
      src/client/js/components/animation.js

+ 26
- 6
src/client/js/components/animation.js Näytä tiedosto

@@ -21,21 +21,27 @@ define([


frameDelayCd: 0, frameDelayCd: 0,


oldSheetName: null,
oldCell: null,
oldTexture: null, oldTexture: null,


init: function (blueprint) { init: function (blueprint) {
if (!this.obj.sprite)
const { template, frameDelay, obj: { sheetName, cell, sprite } } = this;

if (!sprite)
return true; return true;
this.oldTexture = this.obj.sprite.texture;
this.oldSheetName = sheetName;
this.oldCell = cell;
this.oldTexture = sprite.texture;


this.frame = 0; this.frame = 0;
this.frameDelayCd = 0; this.frameDelayCd = 0;


for (let p in this.template)
this[p] = this.template[p];
for (let p in template)
this[p] = template[p];


this.frameDelayCd = this.frameDelay;
this.frameDelayCd = frameDelay;


this.setSprite(); this.setSprite();
}, },
@@ -68,7 +74,21 @@ define([
}, },


destroy: function () { destroy: function () {
this.obj.sprite.texture = this.oldTexture;
const { oldSheetName, oldCell, oldTexture, obj: { sheetName, cell, sprite } } = this;

//Make sure something didn't happen while we were in animation form
// that made us change sprite
if (oldSheetName === sheetName && oldCell === cell) {
sprite.texture = oldTexture;

return;
}

renderer.setSprite({
sprite,
cell,
sheetName
});
} }
}; };
}); });

Ladataan…
Peruuta
Tallenna