Help with swapping bitmaps

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
178
Reaction score
54
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,601
Reaction score
4,611
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,966
Reaction score
13,603
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
178
Reaction score
54
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 Profile Posts

Say, does anyone know any other indie game development forums? Progress on my uni survey has been a little slow, so I wanna look into posting it around a bit more.
Due to the bullies' resurgence on Facebook and Twitter against my friend (and I since I defend), we've decided to move over to tumblr to try to obscure our presence, where we might finally be at peace working on games. If anyone wants my/our game's tumblrs to follow lmk. :kaojoy:
Is there anyone need help with anything except art and music?
is Gotcha Gotcha Games Inc. = KADOKAWA CORPORATION? I haven't found this topic yet, Want to know for credits on my game. Thanks.

Forum statistics

Threads
104,300
Messages
1,005,393
Members
135,825
Latest member
uniteditcare
Top