Help with swapping bitmaps

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
51
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
Moderator
Joined
Nov 18, 2015
Messages
2,234
Reaction score
3,594
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
38,479
Reaction score
12,024
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
51
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

I finally got a book out the door after seven years of nothing \^-^/ Now if I can get a game out the door too, that'd be great...
MY GAME IS NOW OFFICIALLY RELEASED!!
*FurAffinity is down*
*Sets house on fire*
This is fine.
How do you delete your own stupid thread here
Julian Brooks wrote on Hudell's profile.
Hi, I'm trying to use the Orange Mapshot plugin on Mac, but it isn't working. Could you assist? I'm attempting to do Parallax Mapping. Thanks.

Forum statistics

Threads
94,360
Messages
920,238
Members
124,123
Latest member
jfrankmbl
Top