Thanks for the responses, much appreciated! I'm writing a plugin, so this needs to work for arbitrary resolutions and map sizes.
I didn't know about $gameMap.displayX(), that may come in handy! (There are tons of things I don't know about how RMMV works.)
Here's what I'm doing so far. I'm creating a PIXI container that I fill with square sprites that are supposed to sit on top of the map squares. (At a later stage I use these sprites to highlight certain map squares dynamically.) Here's what it looks like in the test phase.
Spoiler: Map with square sprites
I need to fix this container to the top left corner of the
map, rather than the top left corner of the
screen. To do this, I use what little I know of RMMV so far, which is the position of the player on the screen and on the map. I can calculate the correct position of my container from these, and a couple of other things.
Here's how I do it. (Most of the messy bits are just adjustments of coordinates.)
Spoiler: Code
JavaScript:
// Calculate sprite offsets for arbitrary (Yanfly) resolutions and map sizes.
var setWindowWidth = typeof Yanfly != 'undefined' ? Yanfly.Param.ScreenWidth : 816;
var setWindowHeight = typeof Yanfly != 'undefined' ? Yanfly.Param.ScreenHeight : 624;
xScreenOff = (setWindowWidth - $dataMap.width * $gameMap.tileWidth()) > 0 ? (setWindowWidth - $dataMap.width * $gameMap.tileWidth()) / 2 + 1 : 0;
yScreenOff = (setWindowHeight - $dataMap.height * $gameMap.tileHeight()) > 0 ? (setWindowHeight - $dataMap.height * $gameMap.tileHeight()) / 2 : 0;
// Create a PIXI ParticleContainer for rendering the cone sprites.
var partCont = new PIXI.particles.ParticleContainer();
partCont.update = function () {
this.position.x = xScreenOff + ($gamePlayer.screenX() - $gamePlayer.x * $gameMap.tileWidth()) - $gameMap.tileWidth() / 2 < -($gameMap.tileWidth()) ?
xScreenOff + ($gamePlayer.screenX() - $gamePlayer.x * $gameMap.tileWidth()) - $gameMap.tileWidth() / 2 :
xScreenOff;
this.position.y = yScreenOff + ($gamePlayer.screenY() - $gamePlayer.y * $gameMap.tileHeight()) - ($gameMap.tileHeight() - 6) < -($gameMap.tileHeight()) ?
yScreenOff + ($gamePlayer.screenY() - $gamePlayer.y * $gameMap.tileHeight()) - ($gameMap.tileHeight() - 6) :
yScreenOff;
}
// Add the particle container to the scene.
SceneManager._scene.addChild(partCont);
This
almost works. That is, it works except that for maps that scroll because they are larger than the window, the position of the container is updated pixel-wise when the player moves right or down. Everything ends up in the right place, but it looks ugly. (This happens because while the player is in-between squares, $gamePlayer.screenX() is smaller than $gamePlayer.x * $gameMap.tileWidth(), which is the test for when to update the container position. There is a fix for this, I'm sure.)