GameMaker Objects, Sprites, GUI and layering

J

JohnG

Guest
I'm working on a 3-tap golf swing. There are 3 sprites. A bar that depicts power and accuracy. A shot cursor that moves horizontally based on player input (the tap). Finally a marker that indicates where the player set the power. I have all of these sprites mapped to objects that are working perfectly. I can take a shot with varying power and accuracy that can change the flight of the ball.

What I want to do is clean up the display of this shot bar. After the shot is taken, the camera follows the ball and the shot bar stays put and is lost from the view. I have the shot bar reappear at a specified distance beneath the ball once it stops moving.

I want the shot bar to stay at a fixed position at the bottom of the screen and not fall out of view. I have successfully drawn sprites with the Draw GUI event and they appear where desired. The problem with this is I can't interact with the sprites because they aren't objects.

I have tried just putting the shot bar on the GUI level and making the shot cursor and marker appear as objects above it. But this has been futile (I know the GUI is supposed to be the top layer). I have searched for ways to make objects appear above the GUI layer but have not been able to find any solutions. I think I am stuck with using objects that I will have to manually place and move.

Does anyone know a clear cut way to make objects appear above the GUI? Has anyone written a simple script for keeping objects in a fixed position? For visual reference, I've attached a picture of the shot bar, shot cursor and marker.
 

Attachments

K

ktiix

Guest
What do you mean when you say you can't interact with the objects when they draw their sprites to the gui layer? In the shot bar object, use the draw gui event instead of the draw event. What interaction happens with the shot bar that is lost when you do this?
 

samspade

Member
I'm working on a 3-tap golf swing. There are 3 sprites. A bar that depicts power and accuracy. A shot cursor that moves horizontally based on player input (the tap). Finally a marker that indicates where the player set the power. I have all of these sprites mapped to objects that are working perfectly. I can take a shot with varying power and accuracy that can change the flight of the ball.

What I want to do is clean up the display of this shot bar. After the shot is taken, the camera follows the ball and the shot bar stays put and is lost from the view. I have the shot bar reappear at a specified distance beneath the ball once it stops moving.

I want the shot bar to stay at a fixed position at the bottom of the screen and not fall out of view. I have successfully drawn sprites with the Draw GUI event and they appear where desired. The problem with this is I can't interact with the sprites because they aren't objects.

I have tried just putting the shot bar on the GUI level and making the shot cursor and marker appear as objects above it. But this has been futile (I know the GUI is supposed to be the top layer). I have searched for ways to make objects appear above the GUI layer but have not been able to find any solutions. I think I am stuck with using objects that I will have to manually place and move.

Does anyone know a clear cut way to make objects appear above the GUI? Has anyone written a simple script for keeping objects in a fixed position? For visual reference, I've attached a picture of the shot bar, shot cursor and marker.
The only thing that can appear on 'top' of the gui layer are other things on the gui layer. Game maker draws everything in the draw event first, then starts drawing things in gui layer. For more on this see the event order section of the manual: https://docs2.yoyogames.com/source/_build/2_interface/1_editors/events/index.html.

If you want an object to appear stationary relative to the view, while the room moves, then you have two choices. Either update the object's position relative to the view and use the draw event, or don't update the objects position and use the gui event. For a more detailed explanation see this: https://forum.yoyogames.com/index.p...prites-and-in-game-objects.62013/#post-373637
 
J

JohnG

Guest
What do you mean when you say you can't interact with the objects when they draw their sprites to the gui layer? In the shot bar object, use the draw gui event instead of the draw event. What interaction happens with the shot bar that is lost when you do this?
Thanks for responding. Let me add some missing details. I am drawing the shot bar and shot cursor on the GUI layer. But they're drawn as sprites, not objects. So when I press the button to make the object move, nothing happens. I am trying to figure out a way to make things on the GUI layer functional.
 
J

JohnG

Guest
The only thing that can appear on 'top' of the gui layer are other things on the gui layer. Game maker draws everything in the draw event first, then starts drawing things in gui layer. For more on this see the event order section of the manual: https://docs2.yoyogames.com/source/_build/2_interface/1_editors/events/index.html.

If you want an object to appear stationary relative to the view, while the room moves, then you have two choices. Either update the object's position relative to the view and use the draw event, or don't update the objects position and use the gui event. For a more detailed explanation see this: https://forum.yoyogames.com/index.p...prites-and-in-game-objects.62013/#post-373637
Thanks for the references. I did have a version working once before that updated the position of the objects. But it looked gaudy. I'll this approach again though, using your feedback, and see if I can smooth it out.
 
K

ktiix

Guest
Thanks for responding. Let me add some missing details. I am drawing the shot bar and shot cursor on the GUI layer. But they're drawn as sprites, not objects. So when I press the button to make the object move, nothing happens. I am trying to figure out a way to make things on the GUI layer functional.
Everything that is drawn is drawn as a sprite. You cannot draw an object, you can only draw its sprite. If the gui size is the same as the view size, the interactions should be the same. If they are different resolutions you can try using device_mouse_x_to_gui(device).
 
Top