Hi, I'm trying to learn javascript and I've been messing around with the Command Menu (following a tutorial and trying to change things here and there), but I stumbled upon an issue and I have no idea how to fix it because I don't understand what is the engine doing or why.
I'm trying to put a background image on the Command Menu window, and only there (not the whole screen), so I tried this:
Code:
(function() {
// LOCATION MAIN MENU (COMMAND)
var _Scene_Menu_create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function() {
_Scene_Menu_create.call(this);
this._goldWindow.hide(); // Just for now
this._statusWindow.hide(); // Just for now
this._commandWindow.x = 0;
this._commandWindow.y = Graphics.boxHeight / 2 - (this._commandWindow.height / 2);
this._commandWindow.opacity = 0;
};
// COMMAND MENU BACKGROUND IMAGE & UPDATE
var _Scene_Menu_createBackground = Scene_Menu.prototype.createBackground;
Scene_Menu.prototype.createBackground = function() {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadPicture("Pink3");
this.addChild(this._backgroundSprite);
this._isBackgroundScaled = false;
//this._backgroundSprite.opacity = 255;
};
var _Scene_Menu_update = Scene_Menu.prototype.update;
Scene_Menu.prototype.update = function() {
_Scene_Menu_update.call(this);
if(this._isBackgroundScaled == false && this._backgroundSprite.bitmap.width != 0) {
this._isBackgroundScaled = true;
this._backgroundSprite.scale.x = Number(this._commandWindow.width / this._backgroundSprite.bitmap.width);
this._backgroundSprite.scale.y = Number(this._commandWindow.height / this._backgroundSprite.bitmap.height);
this._backgroundSprite.x = this._commandWindow.x;
this._backgroundSprite.y = this._commandWindow.y;
}
};
})();
The background picture stretches to fit the menu box no matter its position or if i change the screen size, but this happens (the white line is actually a transparent padding I added to check if it made any difference):
Protected download
I have tried playing around with the opacity but it doesn't affect that black blackground, and trying to use a picture with the exact screen resolution but filled with a transparency layer makes it go white like this (I didn't care about the pink position for this one):
Protected download
Sooo any help/advice you could give me it would be welcomed. I tried looking up for some options and the only thing I found was the Window_Base bit with updateBackOpacity() but I have no idea if that is what I'm looking for, or If the problem is the way I'm loading the picture.