Drawing On The GUI Layer

H

Halas

Guest
Is there a way to create an object based on the coordinates of the GUI layer?

What I am trying to do:

For my character information screens, I am attempting to create an Obj_Slot that would be interactable with the player. (To place an item(weapon))
The Menu ( For example, Equipment Screen with slots to equip a weapon) draws on the GUI Layer with OBJ_HUD
The Inventory Slot is drawn with the OBJ_INV_CONTROLLER

I am having difficulties to draw both of these at the same time.
I am not sure how to find the correct X and Y locations to draw the Inventory Slot where it shows on the Equipment Screen.

Thanks in advance

CHAR_EQUIP.png
 

Roldy

Member
Need more information.

But I'll make some assumptions:

For your 'Equipment Screen' you are drawing 'slots.' Lets say they are rectangles to mark where the slot is on the screen. You do this during DRAW GUI of OBJ_HUD.
You also want to draw the equipment that is in that slot at the same location. Currently you want to do that with OBJ_INV_CONTROLLER. I am assuming that is because that object has the item information.

What I would suggest is to have OBJ_HUD do all the drawing. Draw the rectangle for the slot, then draw the sprite for the item in the same place. OBJ_HUD can retrieve whatever information it needs about the inventory or items from OBJ_INV_CONTROLLER.

If that doesn't make sense, or doesn't work for you. Then I would suggest you post your code and explain in more detail about what you are wanting to do.
 

Roldy

Member
How do I find the X and Y coordinated to match the GUI Layer on the Equipment Screen?
Well it looks like your equipment screen is just one big sprite, spr_ex_panel_equipment1, drawn at (menu_x, menu_y) during DRAW GUI.

IF that is the case you would need to know where , in pixels the 'slots' are in that image and offset them by that much... e.g. slotX = menu_x + offset_of_slot_in_sprite_x. Something like that.

If you are wanting OBJ_INV_CONTROLLER to know menu_x, menu_y from OBJ_HUD, then just reference them.

GML:
var _panelX = OBJ_HUD.menu_x;
var _panelY = OBJ_HUD.menu_y;

panel_open(global.inv_equipment, obj_inv_equip, _panelX, _panelY, layer);
 
Last edited:
H

Halas

Guest
This isn't working for me.

How can I check if this panel is created and where it is created?
 
Last edited by a moderator:

samspade

Member
Is the image you posted in the original post a single image? And then you want an another sprite (such as the sprite of the equipment) overlayed on top of it? If you're using a single sprite for the image, what is that sprites origin and what is the origin of the sprites that you want to overlay?
 
H

Halas

Guest
I would like to draw the OBJ_SLOT above the Equipment Screen.

I have a red dot to point where the OBJ_SLOT is. The dimensions are only 42x42. The origin points would still be noticed if it was in the area. (Tohelp with testing)

Unless its drawing beneath it and I can't see. (How do I fix that?)
 

woods

Member
if its being drawn beneath..
could you draw obj_slot in the end step so it draws after the equipment screen(this makes it drawn on top of?)
 

Yal

šŸ§ *penguin noises*
GMC Elder
I have a red dot to point where the OBJ_SLOT is. The dimensions are only 42x42. The origin points would still be noticed if it was in the area. (Tohelp with testing)

Unless its drawing beneath it and I can't see. (How do I fix that?)
Have the same object draw everything, so you can control the order. You can use with(thatOtherObject){event_perform(ev_draw,0)} style loops to force other objects to draw in your draw event if it's easier to split up drawing code - this works even if the objects you're with-ing are invisible (since "visible" only affects automatic drawing).

Instead of drawing debug points, try drawing debug lines (starting at the center of the screen). That way, it's easy to tell if they're going to where you want them to, or offscreen into the void. If the lines are gradient-colored you can also tell how far away the endpoints are based on if you can see the gradient change or not.
 
H

Halas

Guest
Have the same object draw everything, so you can control the order. You can use with(thatOtherObject){event_perform(ev_draw,0)} style loops to force other objects to draw in your draw event if it's easier to split up drawing code - this works even if the objects you're with-ing are invisible (since "visible" only affects automatic drawing).

Instead of drawing debug points, try drawing debug lines (starting at the center of the screen). That way, it's easy to tell if they're going to where you want them to, or offscreen into the void. If the lines are gradient-colored you can also tell how far away the endpoints are based on if you can see the gradient change or not.
Thanks, this helped me solve the issue.

When staring at a problem for so long, the answer always seems the simplest.
 
Top