Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
if mouse_x and mouse_y are within x1,x2, y1,y2 then draw_sprite(x,y.spr_blah)
not really, what I'm trying to do is build a HUD. I've tried using objects before and they don't work, they're never still so I have to use sprites drawn onto the GUI layer.
I've tried some options before but now I'm trying to use a controller object to control the buttons on the HUD base.
when they should change image_index, what they should do. but nothing is working.
no one else has been able to give me a solution to this problem.
draw your hud in the draw gui step as normal.. then in the end step i believe .. if mouse is in x1x2y1y2 area draw other sprite
idk ')
try this:
if point_in_rectangle(mouse_x,mouse_y,x1,y1,x2,y2)
{
//sprite change code here
}
you will have to do this for all the sprites/sections of your hub that you want your mouse to affect.
for more information on this, as well as other shapes to check for a collision in, check movement and collisions, under references in the help file.
Hope this helps!
edit:
lol sorry it is very late, didnt realize this was said already, still hope this helps. But if not, please give us a clearer picture of what you are trying to do.
Hi I'll try this way, but where should I set the x1, y1, x2, y2 variables?
and is their a certain way I should set them?
I'll give a clearer picture of what I am trying to do:
I am trying to create a hud that is made out of sprites. I cannot use objects on the GUI layer because I can never ether get them to follow the view, or follow it to the point. it tened to have this delay on it when it had to catch up to the view.
I need to get the sprite to work right and also work with the states. its because of the states that I cannot use the draw code outside of the charicter object, as it will only give the "not set before reading" error.
I hope this give a clearer picture of what I need to do. if you know a better way to do the HUD then please tell me
you should be able to use the point_in_rectangle() command in the draw gui event. Worst case scenario is that it doesnt recognize the mouse positions on the screen, because the gui layer uses it's own x and y values. But I'm sure there is a workaround for that if that is the case.
okay, I think I understand better now, but just to be sure, are you going for a drag-and-drop effect? or do you just want to recognize the mouse to use buttons?
edit:
sorry if this makes it confusing, but I just want to correct myself on a small thing. It doesnt actually check for a collision, it "Checks to see whether a given point falls within the defined rectangular area".
though, now that I have given it some thought, the worst case scenario, most likely wont even occur. But we wont really know till you try.
I did do this a while back, but I never knew how to use it
https://www.youtube.com/watch?v=HnYsJWE6-3c
would this help? given that I'm using sprites?
THE WORST CASE SCENARIO DOES HAPPEN. the mouse coordinates are determined by its location in the room, not the screen.
but I did watch about 10 minutes of your video and your solution to the coordinate problem will work and is actually the workaround that I had briefly mentioned before (just not in any detail).
So yes, the point_in_rectangle() function does work. I would post what I have done in the workshop for example...but it is the broken version and I cant be bothered to fix it right now as I have chores to do...
Ok, I have a better understanding of how this works. Its esseintially a little invisible box that when the mouse is inside, an interaction can happen. so I'm building a button object myself in a way.
but how do I place it in the room? I know how to make the rectangle with x1,y1-x2,y2 but how does it know where the sprite is?
I'm writing all this down btw so I never bother steam again with these HUD problems :)
so the workaround will have to be applied to that as well.
as far as it knowing where the sprite is, if you plan on having the sprites be stationary in the gui then you just place the rectangle overtop of it. but if the sprite will be in varied positions then it will be a tad more complicated, especially with the workaround being applied.
for the sprite you will need to create new variables to represent the x and y of the sprite, so that as these variables change, as does the position of the sprite.
then for the rectangle, because of the workaround to make the positioning compatible with the gui, you will need to create special variables for these as well.
sorry if I sound vague or complicated, I'm running out of time to complete my chores before my fiance gets home, so it will be about 2 ish hours before I can get back to you.
Hi been kind of busy so I couldn't try out the code before. I found an alternitive in the comments section of the video. instead of using the system ben showed to get the mouse position on the screen, I could just use:
window_mouse_get_x
window_mouse_get_y
only, the comment told me to place it in the x,y coordinites of the point_in_rectangle function. I thought that told the function where the button sprite was?
if thats in there, how would the function know where the button was to draw the rectangle?
I just tried this code, but nothing happened. can you see anything wrong with it?
if point_in_rectangle (window_mouse_get_x(), window_mouse_get_y() , 32, 32, 32, 32) && hovering = 0 {
with spr_badge_button {
image_index = 1
hovering = 1
}
}
else
{
image_index = 0
}