Status
Not open for further replies.

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
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,164
Reaction score
1,649
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
210
Reaction score
160
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
3,941
Reaction score
4,853
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 Posts

Latest Profile Posts

Another comic with Backstage Malak...
If you want to ask him anything, you can ask on my DeviantArt page! I'm not sure if you're allowed to do it here.
Forum tip of the day ...
If you get a temporary suspension for being a jerk to people who are trying to help you, and arguing with mods and admins, don't go making new accounts. Chances are, if you p**s us off enough to suspend you for a week, we're not going to hesitate giving you a permanent ban when you give us a reason.
E_6fAErVkAQILXu.png
I'm so close to releasing my game on steam! :blush::blush::blush:
Us:
"This game is awesome! I wish there are more games like this in the future."
Also us:
"I hate how games stopped being original and start copying other successful games."
Should've done this a few days ago but...
PRI_200136808.jpg
Rest in Peace, Sir Clive Sinclair
1940 - 2021
Entrepreneur, Technologist, Father of the Modern British Computing Industry, and protagonist of Legend of ZUN.

Without you, England's games and tech industry wouldn't be where it is.

Forum statistics

Threads
115,287
Messages
1,088,662
Members
149,917
Latest member
statdev
Top