The door sprite overlaps my character

Started by Hayoto, Tue 01/11/2022 08:07:38

Previous topic - Next topic

Hayoto

Hello, first of all I would like to thank so many answers that I read before registering in this forum and that have helped me not to abandon my first game.
Second, excuse my English.
Ok, a picture is worth a thousand words.
I think it must be when importing the sprite to define the pixels that should not be used, or maybe I should cut the sprite in another way? I do not know

Okay


https://ibb.co/x7LwJ03



https://ibb.co/wpPZsR0



Khris

#1


Hi, you need to set the object's baseline to a lower Y coordinate (the default is the bottom of the sprite). In its properties set BaselineOverridden to true, this will enable the baseline property and set it to 1 (i.e. the top of the screen). This causes the door to appear behind everything else.

Snarky

#2
Khris posted while I was writing, but here's a bit more explanation of why this is happening and why his solution works:

In AGS, the z-order of characters and objects (which things are in front of which other things), is controlled by their baselines. By default, the baseline is the bottom edge of the character/object. Something is in front of another thing if its baseline is lower on screen than that other thing. (Because the vertical y-coordinate measures from the top and down, lower on screen means a higher y-coordinate value.)

This simple shortcut works out correctly most of the time (because things usually have their bottom edge on the floor/ground, and we usually look at the floor/ground from above, so that the bottom edge being higher up in the picture usually means it's further away), but when you have things with a lot of depth/perspective, like the diagonal line at the bottom of your door, it can fail.

As you can see, the bottom of the door is lower than the bottom of the character, so AGS thinks the door is in front of the character. To fix this, you need to override the baseline of the door, as Khris explains.

Hayoto

Thank you both very much, of course it worked. I was already doing the sprites again.

SMF spam blocked by CleanTalk