mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Slight performance improvement, previewfilmcontroller still buggy
This commit is contained in:
@ -3,7 +3,9 @@
|
||||
ns.AnimatedPreviewController = function (framesheet, container, dpi) {
|
||||
this.framesheet = framesheet;
|
||||
this.container = container;
|
||||
this.animIndex = 0;
|
||||
|
||||
this.elapsedTime = 0;
|
||||
this.currentIndex = 0;
|
||||
|
||||
this.fps = parseInt($("#preview-fps")[0].value, 10);
|
||||
this.deltaTime = 0;
|
||||
@ -15,11 +17,6 @@
|
||||
};
|
||||
|
||||
ns.AnimatedPreviewController.prototype.init = function () {
|
||||
this.initDom();
|
||||
this.renderer.init(this.framesheet.getFrameByIndex(this.animIndex));
|
||||
};
|
||||
|
||||
ns.AnimatedPreviewController.prototype.initDom = function () {
|
||||
$("#preview-fps")[0].addEventListener('change', this.onFPSSliderChange.bind(this));
|
||||
};
|
||||
|
||||
@ -27,12 +24,17 @@
|
||||
this.fps = parseInt($("#preview-fps")[0].value, 10);
|
||||
};
|
||||
|
||||
ns.AnimatedPreviewController.prototype.render = function () {
|
||||
if (!this.framesheet.hasFrameAtIndex(this.animIndex)) {
|
||||
this.animIndex = 0;
|
||||
ns.AnimatedPreviewController.prototype.render = function (delta) {
|
||||
this.elapsedTime += delta;
|
||||
var index = Math.floor(this.elapsedTime / (1000/this.fps));
|
||||
if (index != this.currentIndex) {
|
||||
this.currentIndex = index;
|
||||
if (!this.framesheet.hasFrameAtIndex(this.currentIndex)) {
|
||||
this.currentIndex = 0;
|
||||
this.elapsedTime = 0;
|
||||
}
|
||||
this.renderer.render(this.framesheet.getFrameByIndex(this.currentIndex));
|
||||
}
|
||||
this.renderer.render(this.framesheet.getFrameByIndex(this.animIndex));
|
||||
this.animIndex++;
|
||||
};
|
||||
|
||||
})();
|
Reference in New Issue
Block a user