Hi people!
Well, I have lost account of how many times I rewrote my plugin... But I hope that is the last one!
It is a plugin that adds new sprites to the timer. And I'm unsure about the performance of the update functions of them.
I have made two versions:
1 - Used only the Sprite_Timer and made every other sprite inside. Like the gauge sprite:
this.gauge = new Sprite();
this.gauge.bitmap = new Bitmap(96,48)..
And so on.
There is a maximum of 7 sprites new.
Although I divided it with comments and proper functions names(Sprite_Timer.prototype.gauge...) I think that is a little unorganized.
So here, the Sprite_Timer.prototype.update carries all the update functions to all sprites.
2 - Made a class sprite for every sprite:
Sprite_timerBackground.prototype...
Sprite_timerGauge.prototype...
That seems cleaner to me, and more readable.
But now I have an update function for each sprite.
________________________________________________________________________________
So if before(method 1) I have made an only one check in Sprite_Timer that goes for every sprite:
Now(method 2), in some sprites, I have this check again in the other update functions, in 3 or more times, because other sprites need the update to, like the gauge one for every second the timer goes.
So, how do you think about that?
Should I stick with method one? Or go with method two for a more readable code?
Well, I have lost account of how many times I rewrote my plugin... But I hope that is the last one!
It is a plugin that adds new sprites to the timer. And I'm unsure about the performance of the update functions of them.
I have made two versions:
1 - Used only the Sprite_Timer and made every other sprite inside. Like the gauge sprite:
this.gauge = new Sprite();
this.gauge.bitmap = new Bitmap(96,48)..
And so on.
There is a maximum of 7 sprites new.
Although I divided it with comments and proper functions names(Sprite_Timer.prototype.gauge...) I think that is a little unorganized.
So here, the Sprite_Timer.prototype.update carries all the update functions to all sprites.
2 - Made a class sprite for every sprite:
Sprite_timerBackground.prototype...
Sprite_timerGauge.prototype...
That seems cleaner to me, and more readable.
But now I have an update function for each sprite.
________________________________________________________________________________
So if before(method 1) I have made an only one check in Sprite_Timer that goes for every sprite:
Code:
Sprite_Timer.prototype.updateBitmap = function() {
if (this._seconds !== $gameTimer.seconds()) {
this._seconds = $gameTimer.seconds();
// update all things that need update
}
};
So, how do you think about that?
Should I stick with method one? Or go with method two for a more readable code?

