I'm working with some of the sprite-drawing code in the SRPG_core plugin, and specifically trying to get the range indicators to draw under the events instead of over them.
Initially I figured I could just mess with the .z value of the sprite object, but that doesn't do anything- by default, the z value is undefined from the sprite's creation, initialization, and even after it's been drawn for a while.
While digging through the code, I found a list of z values associated with things like the different layers of the tile map, but I can't find where the z values are actually being used, or why some sprites don't seem to use them.
Am I just missing a step in the setup, or is there more that needs to be done?
Spoiler tags for all the relevant sections of plugin code, as far as I can tell.
[EDIT: Solved]
While toying around further and comparing it to other code, I seem to have found the issue- the Sprite_SrpgMoveTile list was being added to the _baseSprite, rather than the _tilemap, which put them on a layer above everything on the tilemap itself. Further, they didn't need a z position because that seems to be part of the tilemap's specific mechanics.
Initially I figured I could just mess with the .z value of the sprite object, but that doesn't do anything- by default, the z value is undefined from the sprite's creation, initialization, and even after it's been drawn for a while.
While digging through the code, I found a list of z values associated with things like the different layers of the tile map, but I can't find where the z values are actually being used, or why some sprites don't seem to use them.
Am I just missing a step in the setup, or is there more that needs to be done?
Spoiler tags for all the relevant sections of plugin code, as far as I can tell.
Initialized with this code
Occasionally moved around by this code
Added to the sprite list (lower layer) by this code
Code:
Sprite_SrpgMoveTile.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.createBitmap();
this._frameCount = 0;
this._posX = -1;
this._posY = -1;
this.visible = false;
};
Sprite_SrpgMoveTile.prototype.createBitmap = function() {
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
this.bitmap = new Bitmap(tileWidth, tileHeight);
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.blendMode = Graphics.BLEND_ADD;
};
Occasionally moved around by this code
Code:
Sprite_SrpgMoveTile.prototype.updatePosition = function() {
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
this.x = ($gameMap.adjustX(this._posX) + 0.5) * tileWidth;
this.y = ($gameMap.adjustY(this._posY) + 0.5) * tileHeight;
};
Added to the sprite list (lower layer) by this code
Code:
var _SRPG_Spriteset_Map_createTilemap = Spriteset_Map.prototype.createTilemap;
Spriteset_Map.prototype.createTilemap = function() {
_SRPG_Spriteset_Map_createTilemap.call(this);
this._srpgMoveTile = [];
for (var i = 0; i < $gameSystem.spriteMoveTileMax(); i++) {
this._srpgMoveTile[i] = new Sprite_SrpgMoveTile();
this._baseSprite.addChild(this._srpgMoveTile[i]);
}
};
[EDIT: Solved]
While toying around further and comparing it to other code, I seem to have found the issue- the Sprite_SrpgMoveTile list was being added to the _baseSprite, rather than the _tilemap, which put them on a layer above everything on the tilemap itself. Further, they didn't need a z position because that seems to be part of the tilemap's specific mechanics.