I tried to have a crack at replacing the square, that pops up when you click or tap on the map, with a custom bmp. It works, but it seems to revert back to square when you either open the menu or go into battle. Upon map transfer, the custom bmp is used again.
After consulting with Master @ATT_Turan (nyan), he suggested that maybe an overwrite would be better, so I also tried it with the below. The result was exactly the same.
Next, to investigate why it reverts to square, the below was added to the code. The result was now that the bitmap would not revert to square after opening and closing the menu. But would still revert to square after battle. It would again change to the bitmap upon map transfer.
Does anyone have any idea why it reverts to square again (i.e. why the
JavaScript:
// ================================================== //
// ChangeDestinationBitmap.js
// ================================================== //
/*:
* @target MZ
* @plugindesc Changes the BORING square when you click/tap a destination
* @author Werzaque
* @url https://
* @help Free to use and/or modify for any project, no credit required.
*
* @param DestBMP
* @text Destination Bitmap
* @desc The file name of the picture replacing the default square
* @type file
* @dir img/pictures
*
* @param FrameCount
* @desc How fast you want the animation to be
* @min 5
* @default 20
* @type number
*/
void (() => {
'use strict';
const PLUGIN_NAME = "ChangeDestinationBitmap";
const parameters = PluginManager.parameters(PLUGIN_NAME);
var pDestBMP = parameters["DestBMP"];
const pFrameCount = Number(parameters["FrameCount"]);
void (alias => {
Sprite_Destination.prototype.createBitmap = function() {
alias.apply(this, arguments);
if(pDestBMP) {
this.bitmap = ImageManager.loadPicture(pDestBMP); //line to be overwritten in original function
}
};
})(Sprite_Destination.prototype.createBitmap);
Sprite_Destination.prototype.updateAnimation = function() {
this._frameCount++;
this._frameCount %= pFrameCount;
this.opacity = (pFrameCount - this._frameCount) * 6;
this.scale.x = 1 + this._frameCount / pFrameCount;
this.scale.y = this.scale.x;
};
})();
After consulting with Master @ATT_Turan (nyan), he suggested that maybe an overwrite would be better, so I also tried it with the below. The result was exactly the same.
JavaScript:
Sprite_Destination.prototype.createBitmap = function() {
const tileWidth = $gameMap.tileWidth();
const tileHeight = $gameMap.tileHeight();
this.bitmap = new Bitmap(tileWidth, tileHeight);
if(pDestBMP)
this.bitmap = ImageManager.loadPicture(pDestBMP);
else
this.bitmap.fillAll("white");
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.blendMode = 1;
};
Next, to investigate why it reverts to square, the below was added to the code. The result was now that the bitmap would not revert to square after opening and closing the menu. But would still revert to square after battle. It would again change to the bitmap upon map transfer.
JavaScript:
Sprite_Destination.prototype.destroy = function(options) {
if (this.bitmap && SceneManager._scene instanceof Scene_Battle)
this.bitmap.destroy();
Sprite.prototype.destroy.call(this, options);
};
Does anyone have any idea why it reverts to square again (i.e. why the
if(pDestBMP) {this.bitmap = ImageManager.loadPicture(pDestBMP);} seems to not happen) when changing scenes? The reverting upon scene change can be prevented entirely with the below (which is essentially a long-winded way of saying "never destroy"), but I am puzzled why it would do this in the first place...
JavaScript:
Sprite_Destination.prototype.destroy = function(options) {
if (this.bitmap && !(SceneManager._scene instanceof Scene_Battle || SceneManager._scene instanceof Scene_Menu))
this.bitmap.destroy();
Sprite.prototype.destroy.call(this, options);
};