Help with swapping bitmaps

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
53
First Language
English
Primarily Uses
RMMV
The filename is the information you need to load the image. You just need to change the path.
No, it isnt, basically i want to let whoever is making the event to be able to specify both the file path and name so they can load whatever image they want. and still, i cant access what actor is being looked at to load the image so i cant make an informed change to what is getting loaded.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,553
Reaction score
4,565
First Language
English
Primarily Uses
RMMV
What do you mean by "whoever is making the event"?

ImageManager is there to simply load assets into memory. It doesn't care about where those assets will go, it doesn't matter if it's an event, an actor, a battler, a tileset, etc.

Every event you see on the map is an object created via Sprite_Character, which is created via the data of the event. See this function (I'll erase anything not related to events:
Code:
Spriteset_Map.prototype.createCharacters = function() {
    this._characterSprites = [];
    $gameMap.events().forEach(function(event) {
        this._characterSprites.push(new Sprite_Character(event));
    }, this);
    // other stuff
};
So as you can see for every event on the map it creates a Sprite_Character and gives it as a parameter the event data itself (where it gets the characterIndex and the characterName). If you want to put a particular file in the event's note in the editor, that's where you would get it (Sprite_Character contains the Game_Event object that stores the data). See how the Game_Event is contained in Sprite_Character with these two methods:
Code:
Sprite_Character.prototype.initialize = function(character) {
    Sprite_Base.prototype.initialize.call(this);
    this.initMembers();
    this.setCharacter(character);
};

Sprite_Character.prototype.setCharacter = function(character) {
    this._character = character;
};
Then, with the information contained in the _character object in Sprite_Character, the Sprite_Character object loads the corresponding graphics and sets it as the bitmap. Like this:
Code:
Sprite_Character.prototype.update = function() {
    Sprite_Base.prototype.update.call(this);
    this.updateBitmap();
    // other stuff
};

Sprite_Character.prototype.updateBitmap = function() {
    if (this.isImageChanged()) {
        this._tilesetId = $gameMap.tilesetId();
        this._tileId = this._character.tileId();
        this._characterName = this._character.characterName();
        this._characterIndex = this._character.characterIndex();
        if (this._tileId > 0) {
            this.setTileBitmap();
        } else {
            this.setCharacterBitmap();
        }
    }
};

Sprite_Character.prototype.setCharacterBitmap = function() {
    this.bitmap = ImageManager.loadCharacter(this._characterName);
    this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};
So if you want to change anything in the process, that's where you'd have to do it.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,949
Reaction score
13,585
First Language
English
Primarily Uses
RMMV
in rpg_sprites.js

Code:
Sprite_Character.prototype.updateBitmap = function() {
    if (this.isImageChanged()) {
        this._tilesetId = $gameMap.tilesetId();
        this._tileId = this._character.tileId();
        this._characterName = this._character.characterName();
        this._characterIndex = this._character.characterIndex();
        if (this._tileId > 0) {
            this.setTileBitmap();
        } else {
            this.setCharacterBitmap();
        }
    }
};
This goes for all events, vehicles, the player, and the followers.

This is the function called by Spriteset_Map in the code above:
Code:
Sprite_Character.prototype.initialize = function(character) {
    Sprite_Base.prototype.initialize.call(this);
    this.initMembers();
    this.setCharacter(character);
};
So the sprite contains a link to the Game_CharacterBase object (this._character), and that is the superclass of Game_Event, Game_Player, Game_Vehicle and Game_Follower.

For events, the Game_CharacterBase object is where the spritesheet name is defined:
Code:
Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
};
For actors, it's like this:
Code:
    var actor = $gameActors.actor(this._params[0]);
    if (actor) {
        actor.setCharacterImage(this._params[1], this._params[2]);
        actor.setFaceImage(this._params[3], this._params[4]);
        actor.setBattlerImage(this._params[5]);
    }
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
53
First Language
English
Primarily Uses
RMMV
in rpg_sprites.js

Code:
Sprite_Character.prototype.updateBitmap = function() {
    if (this.isImageChanged()) {
        this._tilesetId = $gameMap.tilesetId();
        this._tileId = this._character.tileId();
        this._characterName = this._character.characterName();
        this._characterIndex = this._character.characterIndex();
        if (this._tileId > 0) {
            this.setTileBitmap();
        } else {
            this.setCharacterBitmap();
        }
    }
};
This goes for all events, vehicles, the player, and the followers.

This is the function called by Spriteset_Map in the code above:
Code:
Sprite_Character.prototype.initialize = function(character) {
    Sprite_Base.prototype.initialize.call(this);
    this.initMembers();
    this.setCharacter(character);
};
So the sprite contains a link to the Game_CharacterBase object (this._character), and that is the superclass of Game_Event, Game_Player, Game_Vehicle and Game_Follower.

For events, the Game_CharacterBase object is where the spritesheet name is defined:
Code:
Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);
};
For actors, it's like this:
Code:
    var actor = $gameActors.actor(this._params[0]);
    if (actor) {
        actor.setCharacterImage(this._params[1], this._params[2]);
        actor.setFaceImage(this._params[3], this._params[4]);
        actor.setBattlerImage(this._params[5]);
    }
I am working on shoving a variable i can use into these things, it seems to be working so far, let me mess around with it more.

EDIT: look! i kinda have some progress! it's starting to work
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

bro how do I have over 30 OCs
A good way to mix your own music? What's the learning curve on that?
Would it be better to pay a composer?
What theme for the next windowskin? You'll decide. Tell what you wanna see and I'll try for.
I just saw in a manga an interesting mechanic - setting up a stationary teleport beacon that one can go to no matter where one is in a dungeon. I think it'll work with a similar setup to how I did my airship transition.

Ooh what if you could set up multiple beacons and choose from a list of the beacons you set up?

Hmm...
Actor2_1 added!

Forum statistics

Threads
103,258
Messages
998,390
Members
134,759
Latest member
educhino
Top