RMMV HELP! Cant load a custom image on a specific window.

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
256
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
Hi all!!

I want to load an image on a specific window, in this case, on the Status window (Scene_Status). I have the following code as my function:

Code:
Scene_Status.prototype.drawPicture = function(filename, x, y) {
    var bitmap = ImageManager.loadPicture(filename);
    this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);  
};

And then I call it when you press PGup or PGdown on Scene_Status (cycle actors):

Code:
        Scene_Status.prototype.setCommandWindowHandlers = function() {
        this._commandWindow.setHandler('cancel', this.popScene.bind(this));
        this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
        this._commandWindow.setHandler('pageup',   this.previousActor.bind(this));
        this.drawPicture("Loading", 0, 0)
};

But I get this error attached:.
It is worth mentioning im using Yanfly status menu core and im calling the drawPicture function from there.


Thank you.
 

Attachments

  • error.JPG
    error.JPG
    69.4 KB · Views: 12

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,372
Reaction score
1,780
First Language
EN
Primarily Uses
RMMZ
A scene does not have a contents property by default; you're thinking of a window. :kaoswt:

The blt method (block transfer, a.k.a. "blit") is used to paint [a piece of] an image onto a Bitmap instance. A window's contents is one option; a free-floating Sprite is another option. Depending on exactly what you're doing, you might not even need to use blt (cf rpg_scenes.js, Scene_Title.prototype.createBackground).

In this case it sounds like you should find the appropriate window and blit onto that~
 

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
256
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
Hi @caethyril !! Thank you so much. I was able to draw the picture because indeed, it has to be done on a widow, not a scene. Now, I have another problem, my image is not drawing completely, Im guessing something about the canvas? The image I want to load is supposed to be full screen, yet, it loads incomplete.

Attached you will find how the image loads, the red indicates what parts of the image are missing.

Do you know what I should be looking at?

Thanks!
 

Attachments

  • image.png
    image.png
    672.2 KB · Views: 6

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,372
Reaction score
1,780
First Language
EN
Primarily Uses
RMMZ
Does the window's height/width change after it initializes? If so, the window contents should be created again after resizing...try adding these lines after the window's height/width changes:
JavaScript:
this.createContents();
this.refresh();
Note: this should reference the window that was resized; if you're resizing from a different context, replace this as needed.

Also, some windows recreate their contents as part of their refresh routine, so depending on your window's inheritance chain you might only need to invoke its refresh method.

Hopefully that'll fix it, because I'm not sure what might cause that otherwise... :kaoswt:
 

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
256
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
The problem is, I know super basic JS and im working over lots of plug ins, Yanfly mostly, so i don't know if the width and height changes. BUT I was able to accomplish what I needed it with the create sprite method.

I still will be trying what you said out of curiosity though.

I appreciate your help, I was able to accomplish something that seem soo hard. =) =)
 

Latest Threads

Latest Posts

Latest Profile Posts

When you spend hours working on an optional segment that players will only be in for 2 minutes in a single playthrough. That's the life right there.
I had a kernel panic crash on my current computer for the first time after trying out the latest update on a videogame. I think I'm going to wait until the next update before trying it again. This brought back memories of my old computer and laptop in their final days.
My mind is now broken. I just spent over an hour on this stupid issue.
Trying to get a skill to show text depending on enemy ID to show passives.
Well. I tried to call one passive 'Spirit's Way'. See a problem? No? Neither did I until now!
The apostrophe in "Spirit's" ended the text eval... no wonder I kept getting unexpected input errors...I think I'm gonna cry.
Anterograde Fantasy now has a demo build available!

You know you've been working on RPGMaker for a while when you go to move your projects to a 16 GB USB drive and get told not enough space to do this operation.

Forum statistics

Threads
110,443
Messages
1,053,335
Members
143,514
Latest member
VexingTrack2
Top