[Solved] Getting images to appear below windows

[Solved] Thanks for the pointers, Dreadshadow!


Hi there! I don't usually ask questions, but then again I don't usually work with too much with graphics, so...


I'm trying to figure out how to show Sprite images below windows in a scene.


Attached are the image and plugin file. Place the image in img/pictures/, and call the demo scene with


SceneManager.push(Scene_Demo);


... but I'm sure you already knew that.


Scroll down some more for the code.


Thanks in advance for your help!


Screenshot_1.png


function Scene_Demo() {
this.initialize.apply(this, arguments);
}

Scene_Demo.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Demo.prototype.constructor = Scene_Demo;

Scene_Demo.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
}

Scene_Demo.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);

this.createCommandWindow();

var img = ImageManager.loadBitmap("img/pictures/", "annoyance");
this._image = new Sprite(img);
this._image.x = 400;
this._image.y = 300;
this.addChild(this._image);
}

Scene_Demo.prototype.createCommandWindow = function() {
this._choiceWindow = new Window_ChooseOne(0, 0);
this._choiceWindow.x = (Graphics.width - this._choiceWindow.width) / 2;
this._choiceWindow.y = (Graphics.height - this._choiceWindow.height) / 2;
this._choiceWindow.setHandler('yes', this.yesCommand.bind(this));
this._choiceWindow.setHandler('no', this.cancelCommand.bind(this));
this._choiceWindow.setHandler('cancel', this.cancelCommand.bind(this));
this.addWindow(this._choiceWindow);
}

Scene_Demo.prototype.yesCommand = function () {}

Scene_Demo.prototype.cancelCommand = function () {
this.popScene();
}


function Window_ChooseOne() {
this.initialize.apply(this, arguments);
}

Window_ChooseOne.prototype = Object.create(Window_Command.prototype);
Window_ChooseOne.prototype.constructor = Window_ChooseOne;

Window_ChooseOne.prototype.makeCommandList = function () {
this.addCommand("yes", 'yes');
this.addCommand("no", 'no');
};




Attachments


View attachment Demo.js


annoyance.png
At first glance, I see nowhere any method that sets or override layers. I didn't had the time to check MV scripts and how they work, I will actually check to find any potential methods that you might need to override.I will dump in the spoiler some places that might intererst you. I suggest you open the scripts on notepad++ and take a look.

Spoiler
NOTICE:  I AM NOT SURE THIS CAN HELP YOU, I JUST PINPOINT THAT THERE MIGHT BE SOME METHODS YOU MIGHT ALSO NEED TO OVERRIDE:


rpg_scenes line 57


Scene_Base.prototype.createWindowLayer = function() {
    var width = Graphics.boxWidth;
    var height = Graphics.boxHeight;
    var x = (Graphics.width - width) / 2;
    var y = (Graphics.height - height) / 2;
    this._windowLayer = new WindowLayer();
    this._windowLayer.move(x, y, width, height);
    this.addChild(this._windowLayer);
};


On rpg_windows you should probably check padding


Check also  rpg_core check also lines


6433


6479


6514


6526


6539


6594


6607


6651
Ah-- I found the solution. It is indeed as you say.


You need to change "when" the window layer is created:


(code tags don't support bolding so I'll leave it as text)


Scene_Demo.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    
    // this.createCommandWindow(); we move this down to "after" the image is added


    var img = ImageManager.loadBitmap("img/pictures/", "annoyance");
    this._image = new Sprite(img);
    this._image.x = 400;
    this._image.y = 300;
    this.addChild(this._image);


    this.createWindowLayer();


    this.createCommandWindow();
}

Original thread: https://forums.rpgmakerweb.com/threads/solved-getting-images-to-appear-below-windows.73484/