Virage_Detoldev

Villager
Member
Joined
Jan 6, 2018
Messages
18
Reaction score
7
First Language
Portuguese
Primarily Uses
RMMV
Hello everyone, how are you? I would like someone to help with something. I tried to understand how the creation of the status window works on the menu and I could not, so I decided to create a mask, leaving the windows invisible and using the index of the members to display pictures and etc. Recently I was trying to insert member information into the image, such as level, current and maximum hp, and current and maximum mp. I used the code below for this:

Code:
Scene_Menu.prototype.janelaStatus = function() {
    var totalMembros = $gameParty.members().length;
    switch(totalMembros) {
    case 1:
        // Personagem 1
        this._personagem1 = new Sprite();
        this._personagem1.x = Graphics.width - 590;
        this._personagem1.y = 32;
        this.addChildAt(this._personagem1, 2);
        break;
    case 2: // A ordem dos membros é de do maior pro menor para sobrepor a ordem das pictures.
        // Personagem 2
        this._personagem2 = new Sprite();
        this._personagem2.x = Graphics.width - 628;
        this._personagem2.y = 135;
        this.addChildAt(this._personagem2, 2);
        // Personagem 1
        this._personagem1 = new Sprite();
        this._personagem1.x = Graphics.width - 590;
        this._personagem1.y = 32;
        this.addChildAt(this._personagem1, 2);
        break;
    case 3: // A ordem dos membros é de do maior pro menor para sobrepor a ordem das pictures.
        // Personagem 3
        this._personagem3 = new Sprite();
        this._personagem3.x = Graphics.width - 673;
        this._personagem3.y = 257;
        this.addChildAt(this._personagem3, 2);
        // Personagem 2
        this._personagem2 = new Sprite();
        this._personagem2.x = Graphics.width - 628;
        this._personagem2.y = 135;
        this.addChildAt(this._personagem2, 2);
        // Personagem 1
        this._personagem1 = new Sprite();
        this._personagem1.x = Graphics.width - 590;
        this._personagem1.y = 32;
        this.addChildAt(this._personagem1, 2);
        break;
    }
};

This will check the total members and create a picture for each one. So, on update, I made them appear:

Code:
Scene_Menu.prototype.update = function() {
    Scene_Base.prototype.update.call(this);
  
    //Exibe a imagem dos personagens e os dados deles pelos membros do grupo.
  
    var totalMembros = $gameParty.members().length;
  
    switch(totalMembros) {
    case 1:
        // Personagem 1
        this._personagem1.bitmap = ImageManager.loadPicture($gameParty.members()[0]._name);
        this._personagem1.bitmap.drawText($gameParty.members()[0]._level, 40, 40, 50, 50, 'center');
        this._personagem1.bitmap.fontSize = 50;
        break;
    case 2: // A ordem dos membros é de do maior pro menor para sobrepor a ordem das pictures.
        // Personagem 2
        this._personagem2.bitmap = ImageManager.loadPicture($gameParty.members()[1]._name);
        this._personagem2.bitmap.drawText($gameParty.members()[1]._level, 40, 40, 50, 50, 'center');
        this._personagem2.bitmap.fontSize = 50;
        // Personagem 1
        this._personagem1.bitmap = ImageManager.loadPicture($gameParty.members()[0]._name);
        this._personagem1.bitmap.drawText($gameParty.members()[0]._level, 40, 40, 50, 50, 'center');
        this._personagem1.bitmap.fontSize = 50;
        break;
    case 3: // A ordem dos membros é de do maior pro menor para sobrepor a ordem das pictures.
        // Personagem 3
        this._personagem3.bitmap = ImageManager.loadPicture($gameParty.members()[2]._name);
        this._personagem3.bitmap.drawText($gameParty.members()[2]._level, 40, 40, 50, 50, 'center');
        this._personagem3.bitmap.fontSize = 50;
        // Personagem 2
        this._personagem2.bitmap = ImageManager.loadPicture($gameParty.members()[1]._name);
        this._personagem2.bitmap.drawText($gameParty.members()[1]._level, 40, 40, 50, 50, 'center');
        this._personagem2.bitmap.fontSize = 50;
        // Personagem 1
        this._personagem1.bitmap = ImageManager.loadPicture($gameParty.members()[0]._name);
        this._personagem1.bitmap.drawText($gameParty.members()[0]._level, 40, 40, 50, 50, 'center');
        this._personagem1.bitmap.fontSize = 50;
        break;
    }
};

The sistem works, the pictures (with the actor face) show on Scene_Menu, but the problem is that the texts only appear written the second time that I return to the main menu.

Can someone help me figure out how to fix this?
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
700
Reaction score
629
First Language
German
Primarily Uses
RMMV
The problem is that the bitmap does not get loaded in time. To prevent this, you need to move the code that relies on the bitmap into a load listener.

Here is an example:
Code:
/* ... */
this._personagem1.bitmap = ImageManager.loadPicture($gameParty.members()[0].name());

this._personagem1.addLoadListener(function () {
    this._personagem1.bitmap.drawText($gameParty.members()[0]._level, 40, 40, 50, 50, 'center');
    this._personagem1.bitmap.fontSize = 50;
});

break;
/* ... */
 

Virage_Detoldev

Villager
Member
Joined
Jan 6, 2018
Messages
18
Reaction score
7
First Language
Portuguese
Primarily Uses
RMMV
The problem is that the bitmap does not get loaded in time. To prevent this, you need to move the code that relies on the bitmap into a load listener.

Here is an example:
Code:
/* ... */
this._personagem1.bitmap = ImageManager.loadPicture($gameParty.members()[0].name());

this._personagem1.addLoadListener(function () {
    this._personagem1.bitmap.drawText($gameParty.members()[0]._level, 40, 40, 50, 50, 'center');
    this._personagem1.bitmap.fontSize = 50;
});

break;
/* ... */

So, that means when I open my Menu, the game will wait until all the info is loaded and then open the menu?

Another thing, form some reason when my character level up, the old lever still show under the new one. How can I "erase" the draw text and then load again everytime a open my menu? I try to use on Scene_Menu.prototype.start and use the this.janelaStatus.refresh(), but a error pops up.
 

Latest Threads

Latest Profile Posts

Streaming some game development! Feel free to drop by!
SF_Enemy1_4 added!
index.php

Who wants to see me mock my brother's story? Brother story: thus he summoned a mighty twenty foot lizard. My Comment: Godzilla is attacking the city! As bad as these 4 are at shopping I wouldn't be surprised if Jun didn't proudly return with a chamber pot on her head. "Look at this helmet I got for 1,000 gold!"
Apparently I'm a grandpa now.

20220128_181216.jpg20220128_181227.jpg
Sales Goal of Learn RPG Maker MV at 64% now! :kaopride:

Forum statistics

Threads
118,809
Messages
1,118,874
Members
155,988
Latest member
Lilrick0712
Top