Hi all,
I am attempting to create some custom plugins and having trouble trying to resize the bitmap of a background before it is displayed on screen.
I've mostly been creating and modifying code from the engine code as a starting point and got some things working nicely. However, creating a background sprite doesn't seem to resize the first time the main menu is created.
The bottom part of this image shows the background sprite correctly stretched, but only the second time the main menu is open, and stays that way next. A minor issue, but would like to resolve it.
The code I have to update the background sprite is as follows:
Any ideas why this code wouldn't update the bitmap the first time around or is there a better way to do this?
I am attempting to create some custom plugins and having trouble trying to resize the bitmap of a background before it is displayed on screen.
I've mostly been creating and modifying code from the engine code as a starting point and got some things working nicely. However, creating a background sprite doesn't seem to resize the first time the main menu is created.
The bottom part of this image shows the background sprite correctly stretched, but only the second time the main menu is open, and stays that way next. A minor issue, but would like to resolve it.
The code I have to update the background sprite is as follows:
JavaScript:
function SL_MM_Scene() {
this.initialize(...arguments);
}
SL_MM_Scene.prototype = Object.create(Scene_MenuBase.prototype);
SL_MM_Scene.prototype.constructor = SL_MM_Scene;
SL_MM_Scene.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
}
SL_MM_Scene.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createMainMenu();
this.createActorsView();
}
...
SL_MM_Scene.prototype.createBackground = function() {
const bitmap = ImageManager.loadPicture("Menu_Background");
bitmap.resize(Graphics.boxWidth, Graphics.boxHeight);
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = bitmap;
this.addChild(this._backgroundSprite);
}
Any ideas why this code wouldn't update the bitmap the first time around or is there a better way to do this?