GameMaker Help with DRAW GUI event creating object instances

T

trademike1982

Guest
Hi All,

This is my first post and first of all sorry for my english it is not my mother tongue so I will explain myself as better as I can (and of course thanks for reading this).

I am creating a tower defense game but I am facing some strange behaviours that I could find neither internet or GMS2 manual. That is the problem:

In the Draw GUI event I am placing some instances of the same object that will represent each kind of "Tower" or "Building" you can create (See picture "GUI buttons" attached). Each instance has a different image_index and the player can hover over one object and some info is displayed (See picture "Tower info" attached). At the moment everything is working fine.

The player can move the camera view position using mouse and here is where the problem occurs. If the user moves the camera view position all the GUI objects remains in the same place (awesome) but it seems that its collision mask change....I mean it is out of its original place....

You can check this out in the last attachment "Collision Mask displaced". I just moved the view up and now the mask of all objects has been moved up too....

Do you know what is going wrong here?
I know that others have drawn the GUI with draw_sprite but in my opinión it is very complicated because and object instance gives you more flexibility to capture events and so...

Thanks a lot
 

Attachments

T

trademike1982

Guest
Ok...

  1. I create several object instances on the GUI layer (using DRAW GUI event)
  2. On runtime I move the view
  3. The object sprites remain in the same place but the "clickable" area of each one seems to have move with the View
Any suggestions?

Thanks,
 
H

henkeiusagi

Guest
i dunno if i can respond, otherwise has been a long time since was posted this thread

but oh well, i hope this is neither against the rules or if it is too old, [still new here and i am neither started to read the rules]
so, i am facing the same problems, the acual draw gui cant handle the instance create, it makes it but infinity [and i am really not sure how to stop it , even calling events does not work with me]
i suggest that you create a object that have the buttons, and represent them with sprites, also with some gui coding you can do the effect of keeping them on surface of the app where the actual draw gui event is going,
otherwise we are pretty much stuck there, and again, i hope this is not against the rules, neither is too late to try to help :3
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
so, i am facing the same problems, the acual draw gui cant handle the instance create, it makes it but infinity [and i am really not sure how to stop it , even calling events does not work with me]
Make a new topic for the issue and we'll help you out! In general, it's better to make a new topic for anything, and not bump older topics unless there are signs that the OP is still interested in the answer.

Btw, the issue here is that what you draw to the GUI has nothing to do with how input coordinates work, and the simple fix is to offset the input checks by the position of the view. If the OP still wants elp with this, then they should reply and I'll add more info. :)
 
Top