Author Topic: zorder  (Read 2516 times)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
zorder
« on: January 15, 2019, 04:47:25 AM »
zorder - Get/set the Text's order in the applicable draw list. Objects with a lower zorder are drawn first, so that when objects overlap, the one with the higher zorder is drawn on top. Default value is 0.

Code: (Layout) [Select]
local gameInfo = container.add_text("[Year] [Manufacturer]", -1, -1, 1, 1);
setProps(gameInfo, config.gameInfo);

local gameInfoBR = container.add_text("[Year] [Manufacturer]", -1, -1, 1, 1);
setProps(gameInfoBR, config.gameInfo);
gameInfoBR.set_rgb(0, 0, 0);
gameInfoBR.set_pos(config.gameInfo.x+(overscan*0.25), config.gameInfo.y+(overscan*0.25));
gameInfoBR.zorder = -1;

printL("Game Info zorder: " + gameInfo.zorder);
printL("Game Info BR zorder: " + gameInfoBR.zorder);

Code: (Terminal) [Select]
Game Info zorder: 0
Game Info BR zorder: -1

I have two objects. I would like the second object placed under the first. A negative integer does not change the zorder.? Changing the zorder of the second object to 1 places it under the first. Actually, I have no idea. I get whacky results. Does this make sense?

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: zorder
« Reply #1 on: January 15, 2019, 04:52:28 AM »
What version of AM are you using? Because zorder changed after 2.2 (or was it 2.3?). Also consider that zorder doesn't work reliably inside a surface

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: zorder
« Reply #2 on: January 15, 2019, 05:14:39 AM »
What version of AM are you using? Because zorder changed after 2.2 (or was it 2.3?). Also consider that zorder doesn't work reliably inside a surface

2.5.1-12

I found the commit you were talking about.

- zorder attribute can be set to any integer value.  The value stays
  at whatever it is set to (previous behaviour was that all objects
  had a unique zorder value, forced in to the range of 0 to number
  of objects-1)

This is odd.

Changing the zorder of the first object to 1 AFTER creation of the second object results in the first object being drawn on top of the second. Success. Still interesting.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: zorder
« Reply #3 on: January 15, 2019, 06:16:32 AM »
Changing the zorder of the first object to 1 AFTER creation of the second object results in the first object being drawn on top of the second. Success. Still interesting.

I see what you are doing here (isn't this a drop shadow for text?)... I did something similar (but used a clone for the shadow), in my case I have a counter (zordertop) which I keep as a track for the zorder of the topmost object over which I want to put stuff, so I just placed

Code: [Select]
text_shadow.zorder = zordertop + 3
text.zorder = zordertop + 4

But you don't have a fixed reference, and you are placing everything in a container, if this container is a surface results will be pretty unpredictable. Otherwise you could use

Code: [Select]
text.zorder = (text_shadow.zorder + 1)
« Last Edit: January 15, 2019, 06:38:41 AM by zpaolo11x »