Main Actions - Set 2

This section deals with some of the main actions you will use when working with GameMaker: Studio.

The main action sets are full of the most important actions that you will need when working with GameMaker: Studio, and the second set, marked "main2" in the object properties tab, deals with timing, showing information, game control and resource control.

Timing

Set Alarm
With this action you can set one of the twelve alarm clocks for the instance. You select the number of steps and the alarm clock. After the indicated number of steps, the instance will receive the corresponding alarm event. You can also increase or decrease the value by checking the Relative box. If you set the alarm clock to a value less than or equal to 0 you switch it off, so the event is not generated.

NOTE: An alarm with no actions in it will not run. However, even with just a comment and no code, the alarm will count down.

Set Time Line
With this action you set the particular time line for an instance of an object. You indicate the time line and the starting position within the time line (0 is the beginning). Also you indicate whether the time line should start immediately and whether it should loop at the end.

Time Line Position
With this action you can change the position in the current time line (either absolute or relative). This can be used to skip certain parts of the time line or to repeat certain parts.

Time Line Speed
With this action you can change the speed of the time line (either absolute or relative). A speed of 1 is the normal speed. When you e.g. set it to 2 the actions will happen twice as fast and when you set it to 0.5 twice as slow. You can also set a negative speed, in which case the time line is played backwards.

Start Time Line
This action starts the time line from its current position (if it is paused or stopped).

Pause Time Line
This action pauses the time line. Use the start action to let it continue.

Stop Time Line
This action stops the time line and sets the position back to 0.

Info

Display Message
With this action you can display a message in a dialog box. You simply type in the message. If you use a # symbol in the message text it will be interpreted as a new line character. (Use \# to get the # symbol itself.) If the message text starts with a quote or double quote symbol, it is interpreted as an expression. See below for more information about expressions.

URL Open
With this action you can tell your game to open a web page. You need to specify the complete URL for this to work.

Game

Restart Game
With this action you restart the game from the beginning.

End Game
With this action you end the game.

NOTE: If the target module for your game is HTML5, this function will end the game but will not close the tab or browser.

WARNING: If the target module for your game is iOS then this action may block your device, and as such it is strongly recommended that you do not use it for that platform except as a dev tool. Your final game will also be rejected if this action is used when submitting to the respective app store.

Save Game
With this action you can save the current game status. You specify the filename for saving (the file is created in the working directory for the game). Later the game can be loaded with the next action. (Please realize that only the basic game status is save. Things that are for example not saved are the current sound that is playing, and advanced aspects like the contents of data structures, particles, etc.)

Load Game
Load the game status from a file. You specify the file name. Make sure the saved game is for the same game and created with the same version of GameMaker. Otherwise an error will occur. (To be precise, the game is loaded at the end of the current step. So some actions after this one are still executed in the current game, not the loaded one!)

Resources

Replace Sprite
This action can be used to replace a sprite from the contents of a file. You indicate the sprite you want to replace, the filename and the number of subimages in the sprite. Many different images file formats are supported, e.g. .png, .jpg, .tif, and .gif. For a gif file the number of subimages is automatically decided based on the number of subimages in the gif file. Other settings for the sprite, e.g. whether it is transparent or not, are not changed. You can use this action to avoid storing all sprites in the program itself. For example, at the beginning of a level you can replace sprites by the actual character sprites you want to use. DON'T change a sprite that is at that moment being used in an instance in the room. This might give unwanted effects with collisions.

Replace Sound
With this action you can replace a sound by the contents of a file (.wav, .mid, or .mp3). You specify the sound and the filename. This avoids having to store all the sounds in the game itself. For example, you can use different pieces of background music and pick the one you want to play. DON'T change a sound while it is playing.

Replace Background
With this action you can replace a background by the contents of a file. Many different images file formats are supported, e.g. .png, .jpg, .tif, and .gif. You specify the background and the filename. This avoids having to store all the backgrounds in the game itself. DON'T change a background that is visible.


Back: Actions
Next: Control Actions
© Copyright YoYo Games Ltd. 2018 All Rights Reserved