RPG Maker Forums

Hello fellow developers,


I'm completely new to Javascript, though I have work experience in C languages.


As a beginner exercise, I want to do a simple thing: resize an image that I load to fit with the current resolution.


So I have a high resolution image (1920*1080) that I put as a battleback1 for testing (it is from Blazblue btw). When I simply load it with MV, the image is cropped, as it's too big to fit the default resolution.


Now, I'm not trying to have a bigger resolution at this point, but only to adapt my image to the screen. So I did this (sorry for the C syntax ^^'):


var alias_Spriteset_Battle_battleback1Bitmap = Spriteset_Battle.prototype.battleback1Bitmap;
Spriteset_Battle.prototype.battleback1Bitmap = function()
{
    var battleback1 = alias_Spriteset_Battle_battleback1Bitmap.call(this);
    battleback1.resize(Graphics.width,Graphics.height);
    console.log(battleback1.width);
    return battleback1;
}


As you can imagine, this does not work, and I came to understand it was because Javascript does not wait for the image to be loaded before doing stuff with it. When testing I realized something interesting (if you want to look at the attached images, please ignore the position of the other sprites, that's my next assignment!). On the first fight, the BG image is cropped, as if there was no resize. But starting the second battle (without restarting the game), the image has been resized. I assume that's because the image was already loaded somewhere, so it could resize it.


Apparently, I'm doing it wrong. I apologize if this seems really silly...


By the way, I've also tried this:


var alias_Spriteset_Battle_battleback1Bitmap = Spriteset_Battle.prototype.battleback1Bitmap;
Spriteset_Battle.prototype.battleback1Bitmap = function()
{
    var battleback1 = alias_Spriteset_Battle_battleback1Bitmap.call(this);
    battleback1._onLoad()
    {
        battleback1.resize(Graphics.width,Graphics.height);
    }
    return battleback1;
}


I was delighted to see that it worked for the first battle... but after that, the BG is just black for the second and on... ;_;


1stBattle.PNG


2ndBattleAndOn.PNG

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top