Attract-Mode Support > Scripting

zorder

(1/1)

keilmillerjr:

--- Quote from: https://github.com/mickelson/attract/blob/master/Layouts.md#Text ---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.

--- End quote ---


--- Code: (Layout) ---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);

--- End code ---


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

--- End code ---

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:
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:

--- Quote from: zpaolo11x 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

--- End quote ---

2.5.1-12

I found the commit you were talking about.


--- Quote from: https://github.com/mickelson/attract/commit/e53655f697e178dfa0bfe3c1bf350e1afa94c349 ---- 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)

--- End quote ---

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:

--- Quote from: keilmillerjr on January 15, 2019, 05:14:39 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.

--- End quote ---

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: ---text_shadow.zorder = zordertop + 3
text.zorder = zordertop + 4
--- End code ---

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: ---text.zorder = (text_shadow.zorder + 1)
--- End code ---

Navigation

[0] Message Index

Go to full version