How do you do this? If I have an event object, what script do I use to update its bitmap sprite?
You would start with the sprite, not the event object. Something like this,
as part of a plugin:
JavaScript:
sprite.bitmap = yourBitmapReferenceHere;
The engine is structured so that sprites (visual) update based on their character (model); an event object doesn't know anything about its sprite. E.g. a
Game_Event has a corresponding
Sprite_Character: that sprite updates its bitmap, screen coordinates, etc based on values from the event.
Following that structure, the sprite instance would be responsible for updating its own bitmap.
Spoiler: supporting rpg_sprites.js excerpt
JavaScript:
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.isImageChanged = function() {
return (this._tilesetId !== $gameMap.tilesetId() ||
this._tileId !== this._character.tileId() ||
this._characterName !== this._character.characterName() ||
this._characterIndex !== this._character.characterIndex());
};
Like Turan said, you could patch the
isImageChanged method to also return true if the sprite's
_character has a specific property set. Then just set that value on the character when appropriate, e.g.
$gameMap.event(123).needsBitmapRefresh = true;.
So should I be creating a new image file like ATT_Turan said, then setting the event image to that new file name? What do I do about file bloat from creating a new file every time the image is changed?
Why not just retain the data for the altered image? Edit it however many times you like
per playthrough...no point keeping any version other than the most recent though, right?
If you were to overwrite the original, it would change for all playthroughs; resetting it on new game would also reset it for existing saves. That's the main problem I was pointing out. If you instead record 1 image per save file (e.g. as part of the save data, like I mentioned) then that problem disappears.