Status
Not open for further replies.

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
267
Reaction score
237
First Language
English
Primarily Uses
RMMZ
Back again with another question for my custom scene. I have images for my windows, I use them as sprites, but I actually blt their contents to the window itself, and the sprite itself is hidden at all times. I do it this way because it was the first solution I found when involving blt and sprite bitmaps. (I still understand practically nothing about actually working with images, so I stick with the first thing that seems to work.)

An important note, the images are completely redrawn every frame.

When the window is first set up and the image is drawn, everything is fine. But at one point, the window changes size, with one dimension becoming larger than before. However, the drawn image keeps the dimensions of the original window, and doesn't draw the part of the image that was previously outside the window's area. The source image IS larger than the original blt size, and the blt dimensions also reflect the new image size, at least in code. But the rest of the image that should now be visible still isn't being drawn.

I've tried freshly reloading the bitmap through ImageManager, absolutely no change.

Am I missing something fundamental to bitmap drawing? Should I be storing the bitmap elsewhere and using blt on the sprite itself, instead of essentially the other way around?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,902
Reaction score
2,220
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!

For what you want to do, you either need to change the destination arguments of your .blt function.
It can be a little trick at first... (dx, dy, dw, dh)

JavaScript:
Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
    dw = dw || sw;
    dh = dh || sh;
    try {
        const image = source._canvas || source._image;
        this.context.globalCompositeOperation = "source-over";
        this.context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
        this._baseTexture.update();
    } catch (e) {
        //
    }
};

But, I believe there is a better way than using the bitmap alone. Use sprites instead.
Create new sprites and set their bitmaps to the bitmap you want(either using blt or not).

Then, when resizing the window, you just need to change the sprite scale properties to adjust its size proportional to your changes.
 

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
267
Reaction score
237
First Language
English
Primarily Uses
RMMZ
The blt function is called every update, using dynamic values based on the window size. I've also already figured out how to use its parameters, it's how I've gotten as far as I have.

I also DO use sprites, their bitmaps are where the blt sources COME from. That's why I'm confused as to why the resulting image isn't any bigger than before. When the sprite IS shown, the entire image is there, so it's not that the image isn't there in full, it just won't draw in a different size than the original draw did. I've even tested with using just the sprite, and it draws whatever fits in the size given. But I'm using the sprite bitmap as an image source, not the final image. Mainly because I couldn't set its bitmap to blt a section of itself when creating it, for some reason.

Everything in this scene is dynamic and customizable to some degree, which is why this problem exists. Windows can change size, images can change size or even change pictures, all of that is already working.... except getting the image to draw in ALL of its given space after a window resize.

As I said, I've verified that the blt dimensions ARE being correctly recalculated when resizing. It's just the final image that seems to refuse to update.

I think I'm gonna try reversing the setup. Don't know how successful it will be, I've had issues when trying to do this WITHOUT using sprites as the "library". And I'd rather not double up on sprites. I need full blt functionality, it's not just having or scaling images or this wouldn't be an issue.

EDIT: I discovered the setFrame function for bitmaps, which does EXACTLY everything I needed to use blt for. This eliminates the need for about half the things I'd done while trying to figure this out!

So while I still haven't figured out why what I was doing wasn't working, I HAVE now found a simple solution that renders my approach unnecessary, and ends up invalidating the need for this thread.
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
4,029
Reaction score
4,935
First Language
EN, FR
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.
SIGH its so hard to convince my friend that making a game for fun and making one to sell takes different planning. I don't care about weird bothersome ways of doing things in a game made for fun, but when you are planning to market it, there is some stuff that you just have to streamline or cut out.
It might be a little bit boring and tedious, but building that database of armor, items, weapons and skills are super important.

Forum statistics

Threads
124,399
Messages
1,163,332
Members
163,194
Latest member
SSSR
Top