Generic Question, Set Priority of images drawn with script

Otto

Veteran
Veteran
Joined
Apr 24, 2015
Messages
119
Reaction score
70
First Language
Engilsh
Primarily Uses
RM2k3
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 :p ) 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;





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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,363
Reaction score
7,673
First Language
German
Primarily Uses
RMMV
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...
 

Otto

Veteran
Veteran
Joined
Apr 24, 2015
Messages
119
Reaction score
70
First Language
Engilsh
Primarily Uses
RM2k3
I see, thanks for clearing that up :)
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
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.
 

Otto

Veteran
Veteran
Joined
Apr 24, 2015
Messages
119
Reaction score
70
First Language
Engilsh
Primarily Uses
RM2k3
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::DASH::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?
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
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.
 

Otto

Veteran
Veteran
Joined
Apr 24, 2015
Messages
119
Reaction score
70
First Language
Engilsh
Primarily Uses
RM2k3
cool, i think i understood how it works, i'll do some tests ASAP.


thanks :) :) :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,858
Messages
1,017,023
Members
137,565
Latest member
Callmelogann
Top