Drag And Drop Moving behind and in front of a tree

sanghendrix

Member
Hello guys, I'm new to GameMaker Studio and I'm still learning DnD. I'm trying to make a simple depth system that when I move behind a tree, the tree will be on top of the player and also change its alpha and opposite. But there's a problem, I think it has something to do with the box I circled. Everything works well but if I move on top of the tree, it still triggers the system. If you guys can help me out I'd be very appreciated, thank you!

4.png
 
It can't be just "less" than y. Less than y is everywhere from the trees y position to the top of the room, you have to create a "box" instead. The actual positioning of this entirely depends on where the origin is for your tree sprite and player sprite, but the basic gist of it is:

If the players y is less than the bottom of the tree and more than the top of the tree and the players x is less than the right of the tree and more than the left of the tree, change the image_alpha to 0.5, otherwise set it to 1.
 
Top