Hello! I'm trying to make plugin that makes every character in message to smoothly fade in, but for some reason that doesn't work. I use nwjs 0.49.2 so maybe that is the issue. Is there some error in my code?
JavaScript:
(function() {
var _Window_Message_startMessage = Window_Message.prototype.startMessage;
Window_Message.prototype.startMessage = function() {
_Window_Message_startMessage.call(this);
this._textFadeDuration = 0;
};
var _Window_Base_processNormalCharacter = Window_Base.prototype.processNormalCharacter;
Window_Base.prototype.processNormalCharacter = function(textState) {
_Window_Base_processNormalCharacter.call(this, textState);
if (this.isOpen()) {
this._textFadeDuration = 0;
this.startTextFadeIn(textState);
}
};
Window_Base.prototype.startTextFadeIn = function(textState) {
if (!this._textSprite) {
this.createTextSprite();
}
var characterSprite = this._textSprite;
var duration = 20;
if (this._textFadeDuration < duration) {
characterSprite.alpha = 0;
var fadeInterval = setInterval(function() {
characterSprite.alpha += 1 / duration;
this._textFadeDuration++;
if (this._textFadeDuration >= duration) {
clearInterval(fadeInterval);
}
}.bind(this), 1);
}
};
Window_Base.prototype.createTextSprite = function() {
this._textSprite = new Sprite();
this._textSprite.bitmap = new Bitmap(48, 48);
this.addChild(this._textSprite);
};
var _Window_Base_resetFontSettings = Window_Base.prototype.resetFontSettings;
Window_Base.prototype.resetFontSettings = function() {
_Window_Base_resetFontSettings.call(this);
if (this._textSprite) {
this._textSprite.bitmap.fontFace = this.standardFontFace();
this._textSprite.bitmap.fontSize = this.standardFontSize();
this._textSprite.bitmap.textColor = this.normalColor();
}
};
})();