Trang chủ » blog » Hero’s Trail Tutorial: Interfaces, Sound & Pausing | GameMaker

Hero’s Trail Tutorial: Interfaces, Sound & Pausing | GameMaker


This tutorial expands on the Hero ’ south Trail project provided with GameMaker. We ’ ll add all sorts of sound effects to the game, learn how to change the music, program a pause menu screen and a new help screen that shows the controls !
This tutorial has the keep up sections :

Let ‘s beginning look at how sound effects can be played using GML Visual !

Sound Effects

sound effects and music tracks are added as sound assets in the Asset Browser, which can then be played using the “Play
action :
What do the three options do ?

  • Sound” : This is the reasoned asset that we want to play. You can either enter the identify of the sound asset that you want to play, or click on the undefined button to choose an asset from the Asset Explorer.
  • Loop” : This controls whether the sound should replay after it has ended. This is useful for music loops, as you can enable this to keep them playing constantly ; however it should be disabled for voice effects as they should only play once for each action.
  • Target” : If you specify a variable name here, that variable will store the unique ID of the sound that was played. You by and large won ’ t need this unless you want to change the properties for that sound ( like flip and volume ) .

Let ’ s practice this to implement strait effects for the assorted mechanics in our game !

If your game does not have some of the features listed in this tutorial ( i.e. bats, pickups, sequences ), read the Features Index page to follow those tutorials .

Pickup Sounds


We ’ ll first play the phone for when the player picks up a coin :

  1. Go to obj_coin and open its collision consequence with obj_player.
  2. This consequence runs when the player touches the mint.
  3. Add the “Play Audio” action and use it to play the snd_coin sound.
    1. This sound can be found under “Sounds” – > “Items” .


Power Ups / Pickups

Let ’ s now play a sound for our world power ups and pickups, starting with the heart pickup :

  1. Go to obj_player and open its collision event with obj_heart_pickup.
  2. here, play the snd_powerup good ( under “Sounds” – > “Items” ). Make sure to attach it to the chief condition .

You can now play the same sound for the collision events with obj_powerup_speed and obj_powerup_star .
here are some other pickup sounds you can implement — assets for these are already show in the project :

  • snd_key : This should play when the winder is collected by the player ( hint : there is a collision consequence in the obj_key object )

Action Sounds


Let ’ s play a phone when the player swings the sword :

  1. Go to obj_player and open its “Key Press – Space” consequence.
  2. At the end of the event, play the snd_sword_swing reasoned.
    1. This sound is present under “Sounds” – > “Characters” .

undefined here are some other sounds you can implement – assets for these are already stage in the project besides :

  • snd_lever_pull : Play this when the player interacts with the pry ( hint : this happens in a collision event in the obj_lever object )
  • snd_finish_level : Play this when the musician finishes the level ( tip : see the obj_next_level object )
  • snd_player_defeated : Play this when the actor runs out of all hearts and is defeated ( look at Alarm 0 in obj_player, or add a Create event to the obj_player_defeated object )

Sequence Sounds

You can besides play a sound in a Sequence, so let ’ s do that for our “ villain defeated ” sequence :

  1. In the Asset Browser, find the seq_baddie_defeated Sequence and open it.
    1. Make sure your playhead is on the first frame .
  2. In the Asset Browser again, go under “Sounds”, then “Characters” and find the snd_baddie_defeated sound.
  3. Drag that sound into the Track Panel of the Sequence.
  4. You can now change when the heavy plays by moving its asset key on the Dope Sheet .

The Sequence will now play with the audio when a villain is defeated !

Bat Sounds

We ’ ll now play a iteration voice for the bat flapping its wings. Let ’ s do the follow :

  1. Go to obj_bat and add the Create event.
  2. here, play the snd_bat_fly sound with looping enabled. We ’ ll store its ID in a varying called fly_sound so we can stop this specific fathom late.
    1. This strait can be found under “Sounds” – > “Characters” .
    2. The variable should not be impermanent, as we will later need to access it in a unlike consequence .

Let ’ s stop this sound when the bat no longer exists :

  1. Add the Clean Up event to the bat object.
    1. This consequence runs when the exemplify stops existing .
  2. here, use “Stop Audio” to stop the bat ’ s fly sound — enter the varying that was created in the Create event ( fly_sound ) .


Note : Lower your volume now as the sound of all bats will be loud. We will work further on this in the next section.

If you run the bet on, you will hear the bats flapping their wings, however there is one boastfully trouble : you ’ re able to hear all the bats in the flush at once ! Let ‘s make it so you can only hear those near you .

Proximity Audio

ideally, the strait from an object should only play when the musician is near it, and should fade away as the player walks off from it. This is implemented into the base project with the foe, fountains and the torches, and now we ’ ll add that have ourselves to the bat .
For this, we ‘ll need to learn what functions are .


A function is similar to an action, as it takes a certain number of inputs and performs an action. There are a huge numeral of functions available in GameMaker that can be used with the “Function Call” action : undefined
here ’ s what each playing field in this natural process means :

  • Function” : This is the diagnose of the function that we ’ rhenium calling ( or using ).
  • Argument” : This is merely an option that is passed into the officiate. You can press the undefined plus push button on the left to add another argument, if the serve requires it.
  • Target” : This is the name of the variable that stores the resultant role of the function. You can make it irregular by enabling the “Temp” option .

We ’ ll now use a function to implement our “ proximity audio ” feature .

Distance-Based Audio

We ’ re already playing the bat ’ mho sound in its object, so we plainly need to find its distance from the player, and change the volume of its sound consequently. The close the player is, the forte the legal will be .
Let ’ s do the follow :

  1. Go to obj_bat and open the End Step event. We ’ ra using end step as it runs after all instances have moved.
  2. here, add the “If Instance Exists” action ( this is a condition ) and check if obj_player exists. We ’ rhenium doing this to make sure the main player aim is active ( and not the get the better of one ).
  3. Attach a “Function Call” natural process to the stipulate and use it to call the point_distance serve. This routine calculates the distance between two points.
  4. It takes four arguments : the first two are the coordinates of the first point, and the last two are the coordinates of the second

    1. Our first point will be the bat ‘s own position ( merely x and y ) and the second point will be the player ‘s place ( obj_player.x and obj_player.y ) .
    2. You need to add three more argument fields by clicking on the summation push button .
    3. This distance will be stored in a impermanent variable called distance .
  5. After that, use the “Set Audio Volume” action to change the volume of the bat ’ s fly_sound to 50 / distance. This means that the sound will play at full volume when the bat is precisely 50 pixels away from the player, and after that it will get faint .

Use the follow settings for the new actions :

Run the game now, and you will notice that the bat sounds can ’ triiodothyronine be heard anymore. You will only hear it if you go near a bat, which is precisely what we wanted !
here is another bat sound that you can play :

  1. snd_bat_shoot : Play this when a bot shoots ( hint : Do that in its Alarm 0 event ) .
  2. snd_bat_defeat : Play this when the bat stops existing ( trace : Do that in the collision consequence with the sword ) .

And here are some other features that besides need healthy effects ( the sounds for these are besides introduce in the project ) :

  1. Chests. You can play snd_chest_locked when the player tries to open a locked chest, and snd_chest_open when it actually opens.
  2. Energy Shield. You can play snd_shield_activate in the shield object’s Create event, and snd_shield_deactivate in its Clean Up event.
    1. You can also play snd_shield_loop with looping enabled when the shield is created, and stop it when the shield is removed.
  3. Gates. You can play snd_gate_iron_open when the lever is pulled and the gate opens.

Changing Music

We ’ rhenium now going to switch the crippled music to another cut ( snd_music_rampage ) while the indomitability ability up is active. After the power up is over, the music will switch back to the regular track ( snd_music_game ) .
hera ’ s how we ’ ll play the rampage track :

  1. Go to obj_player and open its collision event with obj_powerup_invinc.
  2. This event runs when the player collects an indomitability baron up, and we ’ ll change the music track here.
  3. first add a “Pause Audio” action and use this to pause the game music ( snd_music_game ).
  4. then add a “Play Audio” military action and use this to play the rampage music ( snd_music_rampage ). Make sure to enable looping .

This will now switch the music from the plot track to the rampage track when you collect the indomitability exponent up. Let ’ s now handle how the music will switch bet on once the power up is over :

  1. Open the Alarm 1 event of the actor object, which handles deactivating a office up.
  2. here, add the “If Audio Is Playing” action to check if snd_music_rampage is playing.
  3. If it is, use “Stop Audio” to stop that track ( attach it to the circumstance ).
  4. then add the “If Audio Is Paused” action to check if snd_music_game  is paused.
  5. If it is, function “Resume Audio” to resume the game track ( attach it to the condition ) .

here is how your new actions should look :undefined
This will stop the rampage music if it’s playing, and resume the plot music if it’s paused. now run the game and collect the star topology ability up. You will hear the music change, and after the world power up is over, the game will switch back to the old track .

Pausing the Game

One of the most essential parts of any game is the ability to pause it. Our pause system will involve two mechanics :

  1. Stopping the game ’ s action
  2. Displaying a pause menu

In this section, we ’ ll work on the first one – stopping the game ’ south bodily process. This just involves deactivating objects so that they stop running their events, and late reactivating them so the game resumes. All of this will happen with the weigh of the “Escape” cardinal .
Let ’ s first create a new variable for pause :

  1. Go to obj_manager and open the Create event .
    1. This object can be found under “Objects” – > “Game”.
  2. here, create a variable called pause and set its value to false .



We ’ ll immediately tell the object to pause the game when Escape is pressed, by doing the follow :

  1. Go to obj_manager and click on “Add Event”.

    Go under “Key
    , then “Others” and blue-ribbon “Escape” — this event will run when the Escape winder is hit.

  2. here, add a condition to check if pause is equal to false, meaning that the game is not presently paused.
  3. In that sheath, manipulation “Function Call” to run the
    affair, which merely deactivates all instances.
  4. This affair takes one argument that tells whether the current example should stay active or not. In this context the “ current exemplify ” is the director as that ’ randomness where the event is.
  5. We want the director to stay active so that it can resume the crippled when it needs to, so we ’ ll set the argument to true ( meaning it should keep the stream example active voice ).
  6. then change the pause variable to true .



The event above will pause the bet on, but we besides need actions to resume it. Let ’ s do the take after in the lapp Step event :

  1. Add the “Else” military action below the “If Variable” condition. Since that condition runs when the plot is not paused, the “Else” action will run when the game is paused.
  2. Attach a “Function Call” natural process to the “Else”
    carry through and use it to run the instance_activate_all function.
  3. This function takes no arguments, and just reactivates all instances, efficaciously resuming the game.
  4. After that, change the pause variable spinal column to false .

You can now run the game, urge Escape and you will see all instances disappear. At that target they ’ ve wholly stopped running their events and are basically “ paused ”. You can then press Escape again to return them back to the claim state they were in when the game was paused .
sol that handles the actual hesitate, immediately let ’ s work on displaying a decent pause menu !

Pause Menu Screen

Let ’ s nowadays create a pause menu screen which will consist of a setting trope and two buttons : Resume and Menu .

Creating the Buttons

We have a rear object called obj_button_parent that already has all button behavior program. We just have to create objects that are children of that parent, and we ’ ll have fully functional, customs buttons in no time !
Let ’ s do the following to create a Resume button :

  1. In the “Objects” group, select the “Menu” group and create a new object called obj_resume_button.
  2. Assign the spr_button fairy to this, which can be found in the “Menu” group under “Sprites”.
  3. Open its Parent menu and set its rear to obj_button_parent.
  4. You will now see all of the parent ’ s events in this object .

Button Text

Let ‘s change the text shown on the button, which is set up in the Create event as a variable .

  1. Find the “Create” event for this object, right-click on it and select “Inherit Event”.
  2. This event will automatically get a “Call Parent Event” action, which simply runs the parent object’s version of the event.
    1. This way, both the parent’s and the child’s versions of the event are called.
  3. Add an “Assign Variable” action and use it to set the value of the text variable, which stores the text string that is displayed on the button.
  4. Set its value to “Resume” (with quotes, as this is a string).


Button Behaviour

We ‘ll nowadays plan this release to resume the bet on when the player clicks on it .

  1. To program this clitoris ’ south behavior, we need to add to the “Left Released” event, which runs when the sneak has been lifted off the button.
  2. right click on the “Left Released” consequence and inherit it.
    undefined This will allow us to add actions to this event, and will besides run all existing actions in the parent ’ s event because of the “Call Parent Event” military action that was mechanically added.
  3. Add the “Assign Variable” action here and set the obj_manager ’ s pause variable to false.
  4. then add the “Function Call” carry through and call instance_activate_all to resume the game .


Menu Button

The “ menu ” clitoris will take the exploiter back to the main menu. Creating this button will be similar to creating the resume button :

  1. Create an object called obj_menu_button and assign the spr_button fairy to it. Make it a child of obj_button_parent.
  2. Inherit its “ Create” event and change its text variable to “Menu” ( or some early text that you ‘d like for this button ! )

Let ‘s course of study its behavior now :

  1. Inherit the “Left Released” event.
  2. In the event, add the “Go To Room” military action, which is used to change the room.
  3. Set the “Room” choice to rm_menu so the exploiter is taken back to the menu room .
    1. This is how simpleton it is to change rooms !


Making the Pause Sequence

The buttons for our hesitate menu are quick, so we ’ ll now design the menu interface in a sequence .

For an introduction to Sequences, add the enemy defeat animation to your game .

Let ’ s do the follow :

  1. In the Asset Browser, select the “Sequences” group and create a new Sequence asset. name this seq_pause_menu.
  2. In the Toolbox, open the Canvas Frame Settings and change the settings to the postdate :
  3. The Width and Height are set to 1280 and 720 as that ’ s the settlement of our game.
    The Origin X and Origin Y are set to negative values that are half that resolution, so that the origin is placed in the top-left corner of the Sequence ( by default the origin is in the center ).
  4. At the circus tent of the Dope Sheet, on the very correctly, you will see a plain that stores the total length of the Sequence ( in frames ) ; by default it may be set to 60.

    variety this to 1 alternatively as this will be a electrostatic, non-animated Sequence.

This finishes up our Sequence set-up, and we can nowadays start adding tracks to it to build our pause menu interface !

Adding a Background Image

We ’ ll add a background image to this Sequence, which will serve as the background for the pause menu. We ‘ll use the like image that is used in the main menu !

Let ’ s do the follow :

  1. In the Asset Browser, clear “Sprites”, then “Menu” and find the spr_menu_background  fairy.
  2. Drag this fairy into the Track Panel or Canvas of the Sequence.
    1. It ‘s better to drag it immediately into the Track Panel as it will mechanically be placed at the correct stead, filling the Sequence wholly :

Placing the Buttons

We ’ ll now place our newly created Resume and Menu buttons in this sequence :

  1. First of all, make sure your playhead is on the first frame on the Dope Sheet, otherwise, by default, the buttons will only be visible on the selected frame ( if you placed it at another frame by error, you can simply move the asset key spinal column to the foremost frame ).
  2. In the Asset Browser, open the “Objects” group and then go into “Menu”.
  3. Find the obj_resume_button object ( the one we precisely created ) and drag it into the Canvas. You can move it about and place it wherever you like !
    1. The release looks empty right now since its actions are not being executed, but once you ‘re in-game, you will see the “Resume” text on it !
  4. Do the like for obj_menu_button : drag it into the Canvas and place it wherever you like .

Our pause menu is now fix, and we alone have to display it in the game !

New Asset Layer

We want the pause menu to appear above everything in the game, so we ’ ll create a new layer for it and display it there. Let ’ s do the follow :

  1. Open the rm_level_1 board.
  2. In the Layers panel, click on the release shown below to create an “Asset Layer” — this type of layer is used to display sprites and Sequences.
  3. name this layer “ GUI ” ( without quotes ) and place it at the top of the Layers list.
  4. nowadays repeat the same for rm_level_2 as it besides needs to have this layer for the hesitate menu to work .

Showing the Pause Menu

We ’ ll now show the pause menu Sequence when the Escape key is pressed. For that we ’ ll first base need to get the X and Y position of the camera, and then display the pause menu at the camera’s
so the actor can see it .

We ‘ll need to use the television camera ‘s position to create the Sequence because Sequences are drawn inside the room, and not on the screen door directly .

Let ‘s do the follow :

  1. Go to obj_manager ( inside “Objects” – > “Game” )   and open its “Key Press – Escape”
  2. We ’ ll add new actions to the beginning “If Variable” circumstance, which checks if pause is false.
  3. Attach a “Function Call” action to run the camera_get_view_x
    function. This gets the X position of the television camera.

    1. The argument will be view_camera, which points the presently active television camera in the room .
    2. Store the consequence in a impermanent variable called camera_x .
  4. Attach another “Function Call” action to run the camera_get_view_y function, which gets the Y status of the camera .
    1. The argument will be view_camera.
    2. Store the result in a irregular variable called camera_y .
  5. then add the “Create Sequence” action to create the seq_pause_menu sequence on the newly-created “GUI” level ( enter it with quotes ).
  6. We ’ ll create this sequence at the camera’s X and Y position, and store the ID of the Sequence in a variable called pause_seq ( not irregular ) .

Use the pursuit settings for your actions : undefined
This will immediately show our hesitate menu Sequence when we press Escape !

Closing the Pause Menu

We now need to close this menu when the game is resumed. In the same event ( “Key Press – Escape” ), we ’ ll do the keep up :

  1. Add a “Destroy Sequence” military action and impound it to the “Else” action. This will run when the game is resumed.
  2. Use this action to destroy the pause_seq Sequence ( which is the variable storing the Sequence case we created ) .

This will nowadays close the pause menu when the plot is resumed, however there is one more put where the plot can be unpaused : the Resume
button. Let ’ s make it destroy the Sequence excessively :

  1. Go to obj_resume_button and open the Left Released event.
  2. Add the “Destroy Sequence” action here besides, and use it to destroy the hesitate menu Sequence.
  3. The pause menu variable will have to be retrieved from the coach aim, as that ’ s where it ’ randomness created ; so you will need to write obj_manager.pause_seq .

You can now run the game, crush Escape and see your pause menu ! Pressing Escape or clicking the Resume button in the menu should take you back into the game .

Animating the Menu

Since we ’ ve created our pause menu in a sequence, you can leverage this by animating your background and buttons !
here ’ s how you can do it :

  1. First of wholly, you will need to change the distance of the Sequence, as it ’ randomness presently set to 1 frame. As an case, let ’ s set it to 30 frames.
  2. You will then need to extend your asset keys so they fit the wholly sequence :
  3. We ‘ll make the background slither in. To do that, use the undefined “Record a new key” button to create two keyframes on the background path.
  4. On the first keyframe, move the background outside the sail. then play the animation and you will see the background chute in !


Animation Curves

Note : This sub-section is optional, and shows you how the sliding movement can be made smoother using curves. If you are not interested, skip to the “Finishing the Animation” sub-section below.

You can make this motion smooth by using Animation Curves :

  1. Expand the spr_menu_background track and select the position track (since we’re only changing the position of the sprite):
  2. Switch to Curve Mode, which allows you to apply Animation Curves to the selected sub-track (in our case, “Position”). This button can be found above the Dope Sheet:
  3. Convert your track to a Curve. This means that the selected sub-track (“Position”) will now use an Animation Curve instead of keyframes.
  4. Finally, open the undefinedCurve Library menu and change the curve from “Linear” to “Smooth”. Notice how the shape changes to an actual curve:


  5. This will result in movement that looks and feels much smoother, as can be seen in the next section below.

Finishing the Animation

future, do the lapp for your buttons : animate them with a slither movement and optionally, apply an Animation Curve. You will have now a pause menu with a dainty sliding animation !

This will make your bet on look much more polish, however do take care to make this vivification quick since you don ’ t want to keep players waiting !

Make certain that your sequence is not marked as loop : near the play controls, the iteration button should be unselected as shown below :

Let ’ s now move on to the last share of this tutorial, where we ’ ll create a help pop-up !

Help Pop-Up

We ’ ll add a new assistant pop-up book in the main menu that displays the controls of our game. This is an essential separate of any game and will be made using Sequences besides !

Creating the Objects

Let ’ s create an object that will serve as our avail windowpane : undefined

  1. In the “Menu” group under “Objects”, create an object called obj_help_window.
  2. Assign the spr_help_window fairy to it.

We besides need an object for the conclude button on this window, so lease ’ s add that excessively :

  1. Create an object called obj_help_close and assign the spr_help_close fairy to it.
  2. Make this object a child of obj_button_parent, as this is besides a button. We ’ ll use it to merely close the help oneself window.
  3. Inherit its “Create” event and set its text variable to an empty string (“”) as we don’t want any text to appear on this button.
  4. undefined

Let ’ s blueprint the actual pop-up book now !

Designing the Pop-Up

We ’ ll create a new sequence and set up our avail window inside it. here ’ randomness how we ’ ll do it :

  1. Create a newfangled Sequence and name it seq_help_window.
  2. Open the Canvas settings from the Toolbox and use the surveil values ( they ’ re the same values we used for the pause menu ) :

Transparent Background

We ‘ll now place a slightly guileless, bootleg background across the Sequence poll to create contrast for the help oneself pop-up book :

  1. In the Asset Browser, under “Sprites” – > “Menu”, you will find a fairy called spr_black_background .
  2. position it in the sequence and make it cover the whole sail – indeed this acts as our background.
  3. Stretch the track’s asset key so it lasts throughout the whole Sequence.

You ’ ll notice that this fairy is slightly guileless, to allow the independent menu to be visible behind the pop-up book. You can make it even more crystalline by adding the “Colour Multiply” parameter to the path and lowering its alpha !

Placing the Help Window

Let ’ s place the actual aid window now :

  1. First of all, make indisputable that your playhead is on the first gear frame .
  2. In the Asset Browser, find the obj_help_window aim and place it in the center of the Sequence Canvas.
  3. space the obj_help_close object into the Sequence, near the top-right corner of the help window .
  4. Make certain to stretch the asset key for both these tracks so they last throughout the whole sequence .

Our avail window is now complete, indeed let ’ s nowadays create a raw release to open this pop-up book !

Help Button

We ’ ll create a new button which will be give in the main menu and will open the help pop-up book Sequence. here ’ s how we ’ ll do it : undefined

  1. In “Objects” – > “Menu”, create a new object called obj_help_button.
  2. Assign the spr_button fairy to it.
  3. Make this aim a child of obj_button_parent, as we do with all button objects.
  4. Inherit its “Create” event and set its text variable to “Help”.


Let ‘s program its behavior nowadays :

  1. Right-click on the “Left Released” event and choose “Inherit Event” to inherit it.
  2. Add the “Create Sequence” action to create the seq_help_window Sequence. Create it on the “GUI” layer, which we ’ ll create later in the menu room.
  3. Set the “Target” for the Sequence to global.help_popup so it stores the Sequence ID in a global variable. We ’ ll late use it to destroy the Sequence.
    1. What is a Global Variable? It ‘s a variable that any instance can access, as opposed to a regular example variable which can alone be accessed in the case that created it. That ‘s why it ‘s called a “ global ” variable star — because it ‘s available globally in the game.
  4. Add the “Jump to Point” action and apply it to obj_button_parent. We ’ ll use this to move all buttons down by 1000 pixels so they disappear, as they should not be functional while the pop-up book is active.

Use the follow settings for your actions :
now go into the rm_menu room and add a “GUI” Asset Layer at the top :

Placing the New Button

Let ‘s place the newly Help push button in the main menu :

  • Under “Sequences”, find seq_menu and open it. This contains the main menu animation and buttons.
  • Place the Help button (obj_help_button) in the middle of the two existing buttons — you may need to move your playhead so you can see the buttons.
    • Stretch its asset key so it lasts till the end of the Sequence.


  • Look at the existing buttons and how they’re animated: each of them has two keyframes; let’s called them Keyframe A and Keyframe B:
    • Keyframe A has the button at 50% scale on both axes. This is where their asset keys begin.
    • Keyframe B has the button at 100% scale. This is where it stops animating.


  • Use this same keyframe set-up to animate your newly-placed Help button, so it animates along with the other buttons.
    • Of course, this is only optional and not a requirement!

All of this should nowadays enable us to open the help window, however we besides need a way to close it .

Closing the Pop-Up

The close push button ( obj_help_close ) should be able to close the pop-up book and move the menu buttons back to their original positions. Let ’ s do the follow :

  1. Open the obj_help_close object and inherit its “Left
  2. here, add the “Destroy Sequence” military action and use it to destroy the Sequence stored in the global.help_popup varying.
    1. The ball-shaped varying is now coming in handy, as we created it in a unlike object ( obj_help_button ) but are nowadays using it in obj_help_close !
  3. then add the “Jump to Point” carry through and apply it to obj_button_parent.
  4. Use this to move the buttons a 1000 pixels up, so they ‘re back in their original positions ( as we moved them a 1000 pixels down to make them disappear ) .

Use the following settings for these actions :undefined
You can now run the game, open the aid window and close it ; you will besides notice that the independent menu buttons disappear while the aid pop-up book is open, so the player wo n’t unintentionally click on them ! undefined
You will see that the window is still blank, so we ’ ll now display the controls inside it !

Displaying Controls


We ’ ll draw our controls as text, so we need to create a limited baptismal font beginning to make our text look fancy :

  1. In the Asset Browser, select the “ Fonts ” group, go to the undefined Create Asset menu and create a Font asset.
  2. diagnose this fnt_controls as this will be used to display our controls.
  3. The baptismal font will open in a Font Editor window in the Workspace. here you can select a baptismal font from the ones installed on your system, change its size and format .

here are the settings we ’ re going with for our baptismal font :
You can download more fonts at Make certain to check the license of any font you download if you plan to release your game !

String Variables

We ’ ll first set up a “string” variable that will store our controls text. A string varying is plainly a kind of varying that stores text rather of numbers .
To create a drawstring variable, you can merely make a fresh variable star and assign some text value to it. That text value has to be inside double quotes, as shown in the first base example below :

Since the second carry through doesn ’ metric ton have quotes around the text, it ’ sulfur actually good looking for a variable called “ Gurpreet ”, which is not what we want !

Controls Text

Let ’ s now set up our controls text by doing the take after :

  1. open obj_help_window and add the “ Create”  consequence.
  2. Add an “Assign Variable” action and create a variable called controls.
  3. Apply the “CONTROLS\n” text to it. This is a regular string that says “CONTROLS”, and the “\n” part merely inserts a channel open frame into the string ( which is like pressing Enter
    on your keyboard ! ).
  4. Add another “Assign Variable” action and assign a string to the controls variable, but this time, enable the “Relative” option. This will add that string to the textbook that already exists in that variable, basically joining them together .

Using this technique, we can keep adding controls to the variable star by adding strings to it :
You will notice that each modern string has “\n” in front man of it. This is simply adding a line break in the begin of each string, so that all the controls don ’ t appear in fair one line. besides make surely that all actions except the beginning one have “Relative” checked !

Drawing the Controls

Let ’ s now draw this text string by doing the comply :

  1. Add the “Draw” event to the obj_help_window object.
  2. Add “Draw Self” to make sure the exemplify itself is drawn.
  3. Add “Set Font” to change the font to the newly created fnt_controls baptismal font, and “Set Text Alignment” to change the text alignment to Center and Middle.
  4. Add “Set Draw Colour” to change the draw coloring material to black so the text is easier to read on the whiten avail window.
  5. Add “Draw Value” and draw the controls variable as the “Value”. The “Caption” airfield should be empty.
    1. Draw it at the relative military position of the example .
  6. finally, reset the draw color to whiten and the text alignment to Left & Top — these are their nonpayment values .


The origin of the spr_help_window sprite
is set to middle-centre, which is where we’re drawing the controls.
We’ve changed the text alignment to make sure it appears with the
correct alignment, however if your sprite’s origin is set to
top-left, you will not get the correct results.

Run the game now, snap on the Help push button and you will see the controls !
now you can animate this help window just like we animated the pause menu. good topographic point keyframes for vivification and optionally apply Animation Curves to make it smoother ! You can besides add more controls ( like “ E ” for interacting ) :


We have completed Hero ‘s trail ! You are nowadays conversant with how GML works and how GameMaker can be used for fast game growth. You are nowadays fix to create your own game from scratch ! Read or watch the Fire Jump series and create your own infinite scroller using GML Visual .

source :
Category : Economy

Post navigation

Leave a Comment

Trả lời

Email của bạn sẽ không được hiển thị công khai.