Generic Question, Set Priority of images drawn with script

Hi,


i'm trying to grasp something about scripting (i don't plan of getting into vxa scripting now, but i'm just toying with it for a wile)


i was wondering, how the priority (z coordinate, if we will, sorry i'm no scripter at all, i don't understand many techincal terms, so bear with me 😛 ) is determined, when two or more script draw something on the screen:


let's take for example, the Dash Stamina script, which allows you to create a small "box" using the window skin, around the stamina bar, and a "Real Time ABS" script which draws HP and MP bars on screen; i edit the size of the box around the Stamina Bar, and i moved it so that it looks like the HP, MP and Stamina bars are on the same box;


pre_1462901796__clipboard02.png



however as you can see, wile some elements (the gold icon and the other one) are staying on top of the box, along with the green stamina bar, te HP (red) and MP (blue) bars are covered from the huge box... hence the question, how do I decide which one goes up and which one goes down?


is it a matter of which order the script have on the list?
I've moved this thread to Learning Ruby and RGSSx. Please be sure to post your threads in the correct forum next time. Thank you.



Scripts is for presenting finished scripts you've written, that's why it needs additional approval...
I see, thanks for clearing that up 🙂
The z-coordinate of any sprite/graphic can be set explicitly to determine how they are layered. If two sprites have the same z-coordinate, then the one drawn later will be drawn on top.
The z-coordinate of any sprite/graphic can be set explicitly to determine how they are layered. If two sprites have the same z-coordinate, then the one drawn later will be drawn on top.



I see; how do I do that? I mean, i suppose I have to put some specific srtring around that portion of the code, for example here is the code for the stamina box and bar:


def initialize
super(0,0, 194, 89)
#
@time = YES:😀ASH::HIDE_AFTER_FRAMES
refresh
#---
$game_player.stamina_backup[:x] ||= self.x
$game_player.stamina_backup[:time] ||= @time
self.x = $game_player.stamina_backup[:x]
@time = $game_player.stamina_backup[:time]
end


(i didn't do that myself obviously)


where would i put the string (and what should i write) in ordere to give the box the lowest priority?
So, windows and sprites have the "z" property that can be used to get/set it. Example:


@window1.z = 100


@window2.z = 101


@sprite1.z =100


@sprite2.z =101


(The default value is 100)


The above code would cause window2 to be drawn above window1. The same goes for the sprites. Now here's where it gets complicated. A windows z value refers to the background and border but not the bitmap used for its contents, i.e. the text and stuff drawn in it. The z value for it is automatically set to the windows z value + 2 in order to ensure that the contents are always drawn on top.


So, if you're drawing things in the windows contents bitmap, then you can't directly change the z value. If, however, those bars/icons are being drawn as separate sprites, then you can try changing their z values until things look right.
cool, i think i understood how it works, i'll do some tests ASAP.


thanks 🙂 🙂 🙂

Original thread: https://forums.rpgmakerweb.com/threads/generic-question-set-priority-of-images-drawn-with-script.61701/