- Views can also be used in two-player games, as they permit you to create a split-screen setup in which in one part of the screen you see one player and in another part you see the other player. A third use is in games in which part of the room should scroll (e.g. With the main character) while another part is fixed (for example some status panel).
- Which type of Game maker do you use? Wednesday, January 29, 2014. How To Make The Screen Follow The Player Hi gamers! This fast post will show you how to make the screen follow your player. This is very helpful when you make a 2-D side-scroller such as Mario.
- It's *probably* not a bug in Game Maker. I use views for a static health bar on a moving screen? Draw_GUI event automatically follow the view and are.
Game Maker Follow Player
GameMaker: View following two objects at once. This example is going to be of great use for everyone making local multi-player games, as well games requiring to display two objects on screen at once generally. Well you could always assign all four separate objects to a parent, and have the screen follow the parent. I hope this helps.
I have a text box element in game on my gui which is loaded in after the user enters the room.
the object hierarchy is:txt_ChatBox>gui_textBox_base>ui_focus_base>ui_base
this is the draw event where everything happens
In game it works but it also adds part of it to the map like this
EDIT: something new I have found is that the one on the map is the physical instance of the control but all the drawing for text happens in the drawGUI call. I.e. the on click handler that give it focus only works on the on map one.
I made the map/physical one move at the start of the drawGUI to where I wanted it to be but it was off from the gui one by a bit during scrolling which could be smoothed out but I don't think that is the right answer (see updated code above).
I have a feeling I need to say please be part of the view rather than part of the map right??
1 Answer
To draw something fixed on the screen, you have two common options:
The Draw Event
Game Maker Follow Screens
This Event will draw Sprites, Pixels, Lines, etc within the Room. In order to make this appear in the same place, you'll need to offset whatever you're drawing with view_xview
and view_yview
. Note that both of these are arrays, so you should use whichever view you're using for your main display. If that made no sense to you, then just use view_xview[0]
and view_yview[0]
.
This approach has some drawbacks. If you scale or rotate the view, whatever you've drawn will scale and rotate too. Seeing as that's probably not what you want, then I recommend the other approach.
The Draw GUI Event
Rather than drawing within the Room, this Event will draw on the screen. As such, you should use coordinates that match this. To determine the width and height of your display, use the display_get_width()
and display_get_height()
methods.
This is by far the preferred method, as you'll be drawing to the screen, rather than within the room. This method also supports view scaling and rotation, as you're drawing to the screen directly.
Boom