diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm b/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm index 52e0d5e4f..832c7e997 100644 --- a/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm +++ b/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm @@ -4,7 +4,7 @@ async_load - + @@ -14,37 +14,37 @@ -

async_load

-

This variable is global in scope and is used to hold a DS map when used in the Asynchronous Events, and -1 at all other times. The actual contents of the DS map will depend on the type of asynchronous event callback, as well as the function that was used to trigger the event, so refer to the individual pages for those events for full details of all the possible DS map contents.

+

async_load

+

This variable is global in scope and is used to hold a DS Map when used in the Asynchronous Events, and -1 at all other times. The actual contents of the DS map will depend on the type of asynchronous event callback, as well as the function that was used to trigger the event, so refer to the individual pages for those events for full details of all the possible DS map contents.

 

Syntax:

-

async_load;

+

async_load

 

Returns:

-

DS Map ID

+

DS Map

 

Extended Example:

sprite =  sprite_add("site.com/path/image.png", 16, true, true, 0, 0);

-

The above code would be called in an event to load a sprite from an external URL. This would then trigger the Image Loaded Asynchronous Event, where you would parse the async_load map:

-

if (ds_map_find_value(async_load, "id") == sprite)
+

The above code would be called in an event to load a sprite from an external URL. This would then trigger the Image Loaded Asynchronous Event, where you would parse the async_load map:

+

if (ds_map_find_value(async_load, "id") == sprite)
{
    if (ds_map_find_value(async_load, "status") >= 0)
    {
        sprite_index = sprite;
    }
}

-

The above code will first check the ID of the async_load map, then check the status of the callback. If the value is greater than or equal to 0 (signalling success) the result from the callback will then be used to set the sprite index of the instance to the newly loaded image.

+

The above code will first check the ID of the async_load map, then check the status of the callback. If the value is greater than or equal to 0 (signalling success) the result from the callback will then be used to set the sprite index of the instance to the newly loaded image.

 

 

 

-

Audio Buffers

+

Audio Buffers

You can use audio buffers to load, save and manipulate audio files within your games. These buffers are created beforehand using the appropriate buffer functions and then you can use the following functions to create a sound to use in your project:

-

 

-

Note that once you have created a sound from an audio buffer, you are not creating a new sound in memory, but rather pointing to the position within the buffer where the sound is stored. You should not change this buffer after a sound has been associated with it otherwise you will get unexpected results, and you cannot delete the buffer while a sound is associated with it. Instead, free the sound (or sounds) first then delete the buffer.

-

Once you have created your new audio resource from a buffer, you can use its handle in any of the regular audio functions to play it, change its gain or pitch, pause it, etc. Note that the buffer used to load the audio can only support PCM sounds, so formats like OGG will not be supported.

+

When you create a sound from an audio buffer, you are not creating a new sound in memory, but rather pointing to the position within the buffer where the sound is stored. You should not change this buffer after a sound has been associated with it otherwise you will get unexpected results, and you cannot delete the buffer while a sound is associated with it. Instead, free the sound (or sounds) first then delete the buffer.

+

Once you have created your new audio resource from a buffer, you can use its handle in any of the regular audio functions to play it, change its gain or pitch, pause it, etc.

+

 The buffer used to load the audio can only support PCM sounds, so formats like OGG are not supported.

Audio Buffer Queues

Another feature of buffered audio is that you can use a buffer to create a queue of audio which can then be streamed to the device running your project. An audio queue takes a regular buffer which you have previously filled with audio data, and enables you to "point" to parts of it and tell GameMaker to stream the audio in a given order from that buffer. The available functions for audio queues are:

-

Once a queue has been created, you can then use the returned queue index just as you would the sound index for any normal sound to play it, pause it, restart it, or change it's gain and pitch. The only thing you cannot do is get the track length or set the track position, but other than that, an audio queue can be used just like any other sound. You should also note that some of the audio queue functions will also trigger an Audio Playback Asynchronous Event.

+

Once a queue has been created, you can then use the returned queue index just as you would the sound index for any normal sound to play it, pause it, or change its gain and pitch. The few things you cannot do are get the track length, set the track position or use the loop functions, but other than that, an audio queue can be used just like any other sound. You should also note that some of the audio queue functions will also trigger an Audio Playback Asynchronous Event.

+

 Attempting to play an empty queue using the audio_play_sound* functions will not play anything and return a sound instance index of -1. You can queue new audio data after a queue has become empty and then play a new sound from the queue (creating a new sound instance).

Recording

Audio buffers will also permit you to record sound from any of the available sources (like microphones), which can then be queued and streamed using the above functions (for example). Recording audio will trigger an Audio Recording Asynchronous Event which will contain specific information about what is being recorded.

For recording audio, the following functions are available:

-

 

-

NOTE Most platforms except HTML5 support recording audio in some form, but that does not mean that all devices will permit it, even if the platform does, so you should always check that the audio_get_recorder_count() function returns a value greater than 0 to verify that recording devices are available before using the rest of the recording functions.

-

 

+

 Most platforms except HTML5 support recording audio in some form, but that does not mean that all devices will permit it, even if the platform does, so you should always check that the audio_get_recorder_count() function returns a value greater than 0 to verify that recording devices are available before using the rest of the recording functions.

 

 

-
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+
© Copyright YoYo Games Ltd. 2024 All Rights Reserved

Sound Mixer

-

The Sound MixerWhile creating any project it can be useful to check and set volumes of groups of sounds together, so that you can be sure that in-game they all sound correct. This can be tricky when you have to open each individual sound editor within the workspace, and so GameMaker permits you to open a Sound Mixer window where you can play multiple sounds all from the same place and tweak their volume levels accordingly. This window can be opened from the Sound Editor (which will add that selected sound to the mixer view) or from the Tools Menu.

-

To add sounds to the mixer, you can use Control Icon / CMD Icon +LMB Icon to select sounds in the Asset Browser and then open the right click RMB Icon menu and select Open In Sound Mixer. Alternatively, you can click LMB Icon on a sound asset and drag it into the mixer.

+

The Sound MixerWhile creating any project it can be useful to check and set volumes of groups of sounds together, so that you can be sure that in-game they all sound correct. This can be tricky when you have to open each individual sound editor within the workspace, and so GameMaker permits you to open a Sound Mixer window where you can play multiple sounds all from the same place and tweak their volume levels accordingly. This window can be opened from The Sound Editor (which will add that selected sound to the mixer view) or from The Tools Menu.

+

To add sounds to the mixer, you can use Control Icon / CMD Icon +LMB Icon to select sounds in The Asset Browser and then open the right-click RMB Icon menu and select Open In Sound Mixer. Alternatively, you can click LMB Icon on a sound asset and drag it into the mixer.

The mixer itself is split into the following sections:

 

 

-

 

Event Order

-

When considering Events in GameMaker, it should be noted that the exact order that ALL the events are going to occur in each step cannot be clearly stated, simply because it depends on the internal workings of GameMaker and this is subject to change as the software develops or based on the platform where the game is running. However there are certain events that will always run in the same order.

+

When considering Events in GameMaker, it should be noted that the exact order that ALL the events are going to occur in each step cannot be clearly stated, simply because it depends on the internal workings of GameMaker and this is subject to change as the software develops or based on the platform where the game is running. However, there are certain events that will always run in the same order.

Upon Entering a Room

The first set of events that will always happen the same way are those that occur when a room is first entered. The order that the different events will fire is:

-

 You can also set the order in which specific instances are created within The Room Editor itself by moving them up or down the list of the Instance Layer Properties window.

Every Step/Frame

-

Other than those specific events, events in a game step also always occur in the same order. However, the order of the instances within an event is not always guaranteed, and may vary between different Event Order versions and target platforms.

+

Other than those specific events, events in a game step also always occur in the same order. However, the order of the instances within an event is not always guaranteed, it may vary between different Event Order versions and target platforms and may also not correspond to the order in which the instances were created (see Instance Creation Order).

As a general rule, you can rely on the order of the events listed below, but not on the order in which the instances in the room execute one event.

For example, you will see below that the "Step" event always executes after the "Begin Step" event, however you cannot guarantee that, for example, Object2 will always execute its Step event after Object1. If you require such an execution order, then making use of a different event is recommended (e.g. putting Object2's Step code in End Step, if you need it to execute after Object1's Step).

So when you have code that relies on specific timing during each step of your game, make use of the events as listed below. To put it simply, first all Begin Step events are executed, then all Step events are executed, after that all End Step events are executed, then all Draw events, etc.

diff --git a/Manual/contents/The_Asset_Editors/Room_Properties/Room_Properties.htm b/Manual/contents/The_Asset_Editors/Room_Properties/Room_Properties.htm index 9a34784cd..3c464f59c 100644 --- a/Manual/contents/The_Asset_Editors/Room_Properties/Room_Properties.htm +++ b/Manual/contents/The_Asset_Editors/Room_Properties/Room_Properties.htm @@ -22,20 +22,21 @@

Clear Display Buffer

After that you have the option to Clear Display Buffer. This option, when checked, pre-fills the display buffer with a colour before drawing anything else for a particular frame. If you know that your views are going to be covering the whole screen at all times or that you have a fullscreen, opaque background being drawn, then you can un-check this, which saves a redraw and so helps optimise your game.

However if you have multiple views that, when on-screen leave open spaces, or your background has transparent parts - you can check this so any empty areas are filled in with the draw colour of your choice. Currently this colour can only be set through code using window_set_colour().

For clearing views, please see Clear Viewport Background.

-

NOTE If you are using automatic aspect ratio correction (as set in the Game Options), then you should always have this checked otherwise you can get odd effects over the "letterbox" that your game is drawn in. If you do not use this option then you can un-check this and get a small boost to your games performance (especially noticeable on Android and other mobile platforms).

+

 If you are using automatic aspect ratio correction (as set in the Game Options), then you should always have this checked otherwise you can get odd effects over the "letterbox" that your game is drawn in. If you do not use this option then you can un-check this and get a small boost to your games performance (especially noticeable on Android and other mobile platforms).

Width, Height & Other Options

A room has to have a size and this is defined by the values that you input for its width and height in pixels.

-

You can then add the Room Creation Code, should you require it. Creation code is added from the button at the bottom (along with the inherit toggle to say whether the room should inherit it's creation code or not), and if you click it you will open a code or visual editor. This editor allows you to input functions/actions and code that will be run at the start of the room, after the create event of all instances but before their room start event (for more information on event order, please see here). This code will run every time you enter the room, unless the room is flagged as persistent, in which case it will only be run once when the room is first entered, but not on subsequent visits to the room.

+

You can then add the Room Creation Code, should you require it. Creation code is added from the button at the bottom (along with the inherit toggle to say whether the room should inherit it's creation code or not), and if you click it you will open a code or visual editor. This editor allows you to input functions/actions and code that will be run at the start of the room, after the Create event of all instances but before their Room Start event (for more information on event order, please see Event Order). This code will run every time you enter the room, unless the room is flagged as persistent, in which case it will only be run once when the room is first entered, but not on subsequent visits to the room.

Instance Creation Order

The final button in the Room Properties permits you to open the Instance Creation Order window:

-

Instance Creation Order WindowThis window lists all the instances in the room in the order that they will be created (from top to bottom). Should you require a specific instance to be created before any other, you can simply click LMB Icon and drag it to the position your require. Note that instances will be created in the order given from top to bottom of the list.

+

Instance Creation Order Window
+  

 

 

Cameras And Viewports

The next set of properties for the room that you can define are those relating to the room Camera and Viewports. Camera views give a mechanism for drawing different parts of your room at different places on the screen, or for drawing just a part of your room to cover the whole screen. For example, in most platform games, the camera view follows the main character, as, if you could see the whole level on the screen, your character would be too small to see and there would be no surprises for the player. Camera views can also be used in multi-player games or co-op 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. This can all be easily achieved in GameMaker using camera views.

Camera And Viewport PropertiesAt the top of the view properties there is a box labeled Enable Viewports. This must be flagged before any of the camera views can be used in your game.

-

NOTE You can toggle inheritance on or off for the three main viewport settings, and then you can toggle inheritance on or off for each individual camera view.

+

 You can toggle inheritance on or off for the three main viewport settings, and then you can toggle inheritance on or off for each individual camera view.

The next checkbox is the one that says Clear Viewport Background, which is similar to the Clear Display Buffer option given above but for viewports specifically. When enabled, it clears the application surface with the window colour before drawing each frame. This ensures that you don't see any unintended graphics through transparent areas in your background, such as the contents of any previous frames. It's important to enable this option (along with "Enable Viewports") if your background contains any transparency.

Cameras, Views and View Ports

A camera view is defined by two different sets of values, the camera view itself and the port on the screen where this view is to be drawn. This can sometimes cause confusion so let's explain this a bit before explaining how we define each of them:

@@ -46,7 +47,7 @@

Cameras, Views and View Ports

Camera View ExampleSo, for example, this means that you can have a 640x480 camera view into your room, and then set the port to 320x240, which will display the view scaled down to that sized port on the screen, and you can also do the same and set the view to a smaller value and the port to larger making the image scale up to fit the port size and be shown on the screen larger than it is. In this way you can maintain a screen (port) size while changing the camera view to display more or less of the room in the same area of the screen.

Camera and View Port Properties

-

The camera view is always defined as a rectangular area in the room, where you specify the position of the top-left corner, the width and the height of this area. Then you must specify where this area is shown in the window on the screen by defining the view port, where again you specify the position of the top-left corner and the size (note that anything other than 0,0 for the top left corner can give strange results). You can have more than one port and they can overlap, in which case they are drawn in the indicated order one on top of the other.

+

The camera view is always defined as a rectangular area in the room, where you specify the position of the top-left corner, the width and the height of this area. Then you must specify where this area is shown in the window on the screen by defining the view port, where again you specify the position of the top-left corner and the size (note that anything other than 0, 0 for the top left corner can give strange results). You can have more than one port and they can overlap, in which case they are drawn in the indicated order one on top of the other.

Please realise that the overall screen area is always defined as a rectangular area, so your ports, even when offset, will form a rectangle, with any empty spaces being filled in by the window colour of the display buffer, meaning that in these circumstances you should always have Clear Display Buffer checked or else you will get odd artefacts drawn in the spaces between ports. The image below illustrates this, where there are two offset view ports visible, yet they make a square window, and "underneath" there are lines being drawn to the display buffer:

Object Editor Post Draw

Object Following

@@ -56,10 +57,10 @@

Object Following

 

 

Room Physics

-

Before you can use the built in physics functions in your games, you must tell GameMaker that the room is a physics room. To do this, you must tick the option to Enable Physics at the top of the Room Physics section (you can also toggle the inheritance of this section independently of the rest of the room settings). Once you have done that you can then continue on to set up the physics world properties, which are some basic properties that you must have pre-defined before your room will allow physics instances to work as such. For a more precise control over the world you can use code (see the Physics Functions for more information).

-

Room Physics PropertiesThe next thing you must do is set up the Gravity of the world. The strength and direction of this is calculated as a vector of the x/y position that you set around a (0, 0) point. So, an x of 0 and a y of 1 will set the gravity direction as being down with a force of 1 meter per second (for a more detailed explanation see - The Physics World).

+

Before you can use the built-in physics functions in your games, you must tell GameMaker that the room is a physics room. To do this, you must tick the option to Enable Physics at the top of the Room Physics section (you can also toggle the inheritance of this section independently of the rest of the room settings). Once you have done that you can then continue on to set up the physics world properties, which are some basic properties that you must have pre-defined before your room will allow physics instances to work as such. For a more precise control over the world you can use code (see the Physics Functions for more information).

+

Room Physics PropertiesThe next thing you must do is set up the Gravity of the world. The strength and direction of this is calculated as a vector of the x/y position that you set around a (0, 0) point. So, an x of 0 and a y of 1 will set the gravity direction as being down with a force of 1 meter per second (for a more detailed explanation see - The Physics World).

Finally you must set the ratio of Pixels To Meters for GameMaker to use as a base for all its physics calculations. This is because the physics functions work on real-world measurements, which is why we must set this value, and you'll want to adjust this setting until the average pixel size of the objects you are using translates roughly into simulated physics objects of an appropriate size.

-

It should be noted that enabling physics in a room means that all physics enabled instances in the room must use the physics functions and variables to move. Basically, you have "traditional" movement, where you can set the X/Y position of an instance or set its speed and direction, and then you have the "physics" movement, which requires physical forces and impulses to move around. These systems are mutually exlusive, and you cannot move a physics instance using non-physics functions and you cannot move a non-physics instance using the physics functions.

+

It should be noted that enabling physics in a room means that all physics enabled instances in the room must use the physics functions and variables to move. Basically, you have "traditional" movement, where you can set the X/Y position of an instance or set its speed and direction, and then you have the "physics" movement, which requires physical forces and impulses to move around. These systems are mutually exclusive, and you cannot move a physics instance using non-physics functions and you cannot move a non-physics instance using the physics functions.

 

 

 

@@ -67,7 +68,7 @@

Room Physics

Back: The Room Editor
-
Next: Room Inheritance
+
Next: Room Inheritance
© Copyright YoYo Games Ltd. 2024 All Rights Reserved
diff --git a/Manual/contents/The_Asset_Editors/Rooms.htm b/Manual/contents/The_Asset_Editors/Rooms.htm index 2eec0b6a5..e48b2391d 100644 --- a/Manual/contents/The_Asset_Editors/Rooms.htm +++ b/Manual/contents/The_Asset_Editors/Rooms.htm @@ -17,9 +17,9 @@

The Room Editor

The Room Editor is where you create your game rooms. Every game requires at least one room to run, and in the room you can place instances, sprites, tiles, paths, backgrounds, sequences, text and particle systems. Each of these different assets can be placed on their own unique layer which can then be ordered however you wish in the Layer Editor. Due to the complexity of the Room Editor, we'll give you first a brief overview of the most important features, and then you can find more in-depth details from the section links listed below.

-

When you create a room asset, you can right click RMB Icon on it in The Asset Browser to open the context menu, which will permit you to create child rooms (see the page on Room Inheritance for more information), open up the room for editing, add a new asset group to better organise the rooms, rename the room or delete it. Note that to change the room order and/or inheritance you need to use The Room Manager, which you can open using the menu in the top right of the Asset Browser.

+

When you create a room asset, you can right-click RMB Icon on it in The Asset Browser to open the context menu, which will permit you to create child rooms (see the page on Room Inheritance for more information), open up the room for editing, add a new asset group to better organise the rooms, rename the room or delete it. Note that to change the room order and/or inheritance you need to use The Room Manager, which you can open using the menu in the top right of the Asset Browser.

The Room Editor is itself a workspace and as such you can click LMB Icon on the tab and drag it off of the main window into a new window of its own - perhaps in another display, for example. You can also place it back into the main window by dragging the tab to the top of the IDE and releasing the mouse button.

-

The user interface for the Room Editor is simple to navigate and split in various discrete sections. Those parts of the editor that are docked - The Inspector that shows the room or layer properties and the Layer Editor - can also be removed from the dock by simply dragging them out into the workspace, and they can be added back into the docks again by dragging them to the sides or the bottom of the workspace.

+

The user interface for the Room Editor is simple to navigate and split into various discrete sections. Those parts of the editor that are docked - The Inspector that shows the room or layer properties and the Layer Editor - can also be removed from the dock by simply dragging them out into the workspace, and they can be added back into the docks again by dragging them to the sides or the bottom of the workspace.

Below is a brief overview of each of the Room Editor sections:

Rulers / Guides

@@ -85,10 +85,10 @@

The Room Editor

Element List

The Element List appears when a valid type of layer (i.e. one that holds elements) is selected. This includes Instance Layers that hold Object Instances, and Asset Layers that hold visual assets of various types.

-

This list will show you all the elements present in the selected layer. Each entry in the list contains a  checkbox that enables/disables that element. It then shows its icon, asset name and the identifier of that element.

+

This list will show you all the elements present on the selected layer. Each entry in the list contains a  checkbox that enables/disables that element. It then shows its icon, asset name and the identifier of that element.

Clicking on any element in the list will show you its properties in the Inspector:

-

Elements in this list can be re-ordered by clicking LMB Icon and dragging them to the position required. For instances, this is purely for organisational purposes within the Room Editor and if you want to set a specific creation order, use the Instance Creation Order menu, which can be opened from the Room Properties in the Inspector, or from the Room context menu.

-

At the top of the list, you can filter the list with a search string. This string is checked against both the instance identifiers and the asset names. 

+

Elements in this list can be reordered by clicking LMB Icon and dragging them to the position required. For instances, this is purely for organisational purposes within the Room Editor and if you want to set a specific creation order, use the Instance Creation Order menu, which can be opened from the Room Properties in the Inspector, or from the Room context menu.

+

At the top of the list, you can filter the list with a search string. This string is checked against both the instance identifiers and the asset names.

The  menu can be used to detach the list or attach it to any of the four sides of the Room Canvas. You can resize the sidebar by dragging its edge facing the Room Canvas, and clicking on the edge will close the sidebar.

 

@@ -137,7 +137,7 @@

Room Menu