I'm trying to make it so that enemies X and Y positions are calculated right before the battle starts. I need this because the enemy amount and positioning are determined before the battle starts, and not by using the Troop tab in the game database.
The problem is that to position enemies, I need to know their bitmap's width and height dimensions, which I can't figure out how to do thanks to how RMMV works (with async loading and all).
So, what I want to do is something like this:
1) a battle is triggered, screen fades out
2) during the transition, the game decides which and how many enemies are going to fight (this much I can do)
3) position the enemies in the battle scene (I can't do this because I don't know the bitmap dimensions...)
4) battle scene fades in
Any idea on how to do this?
----
I also considered getting all the enemies' sprites width and height before the game started and storing that info in the $dataEnemies array, but I have a similar problem as above...
I got this function here, which tries to save the bitmap width info in the enemy data
Code:
ZNT_Scene_Boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
saveWidth = function(bitmap, _i) {
$dataEnemies[_i].bitmapWidth = bitmap.width
alert(" ok " + _i + " " + $dataEnemies[_i].name + " > " + $dataEnemies[_i].bitmapWidth)
}
for (var i=0; i<$dataEnemies.length;i++){
var enemy = $dataEnemies;
if (!enemy)
continue;
var bitmap = ImageManager.loadEnemy(enemy.battlerName, 0);
bitmap.addLoadListener(saveWidth.bind(this, bitmap, i))
}
ZNT_Scene_Boot_start.call(this);
};
But the problem is that when I'm trying to test a battle from the database, the info isn't available soon enough. I need it before the Game_Troop.setup function is called, but that doesn't happen.