How do I fix label rendering issue?
I tried both factory and collection-factory method but labels always render last and overlaps the card.
Help!!
How do I fix label rendering issue?
I tried both factory and collection-factory method but labels always render last and overlaps the card.
Help!!
Are you by any chance using the system font? The system font material has a separate material tag with id “text” which is rendered in the final step of the default render script and thus drawn on top of everything else.
If you create a new .font file and use the label.material it should be drawn ordered by z-value.
Hi,
I used “kenpixel15.font” from https://github.com/britzl/defold-input
Modified “cursor” project to play around.
I see. Can you share the project please?
Project:
defold-input-master.zip (1.7 MB)
After build. I click on “cursor” button to get the cards.
Ok, so the main problem is that all cards are positioned on the same z-value:
local rdeck_last_card_x = 400
local rdeck_last_card_y = 400
local function remaining_deck_position()
rdeck_last_card_x = rdeck_last_card_x + 1
rdeck_last_card_y = rdeck_last_card_y + 1
return vmath.vector3(rdeck_last_card_x,rdeck_last_card_y,0)
end
The z-value is 0 for all card game objects when created. The label component of each card is on top of the sprite component on the card, and it is given a z-value of 1 * 2.248.
What this means is that ALL card sprite components are positioned on z-value 0 and ALL card label components are positioned on z-value 2.248 which results in all labels being on top of all sprites.
The solution is to assign a z-value on each card to make the card sprite and label component end up on top of the previous card. In your case the z-value increment for each card game object must be larger than 2.248.