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.
Help with swapping bitmaps
Javascript/Plugin SupportWhat 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:
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:
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:
So if you want to change anything in the process, that's where you'd have to do it.
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.
in rpg_sprites.js
This goes for all events, vehicles, the player, and the followers.
This is the function called by Spriteset_Map in the code above:
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:
For actors, it's like this:
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
Original thread: https://forums.rpgmakerweb.com/threads/help-with-swapping-bitmaps.117471/