From 4cd353b05008fee3e1d6082a3cb1a2a1df7183ed Mon Sep 17 00:00:00 2001
From: gurpreetsinghmatharoo The function will write your given value at the buffer's current seek position. The following constants can be used to define the data type: The function will return 0 if it succeeds or -1 if it fails. The function will return 0 if it succeeds or one of the following constants in case of failure: buffer_write(buffer, type, value); Real (0 if success, or -1 if it fails) Real (0 if success) or Buffer Error Constant (if it fails) buffer_seek(buff, buffer_seek_start, 0); The game you create happens in a window (even when fullscreen), and this window has a number of properties, like position, size, whether it is fullscreen, etc. These details are normally set automatically for you based on the room size and view ports enabled in combination with the settings from Game Options for the target platform, but you can change them during the game using the functions listed on this page. These functions are for Windows, Ubuntu, macOS, GX.games and HTML5 targets only and may not work on any other device. The following image illustrates how some general window functions relate and interact with each other: Most actions in the GML Visual libraries have an option to apply the action in different ways. This is called setting the action scope and it can be one of several things: Essentially what you are telling GameMaker is the which instance should run the action. The default action scope
- is self, which means that once the object is created as an instance in the room, that instance will run the action code. However this isn't always what you want, and you may want some actions to affect other, or even
- all, instances in the room. This is where changing the action scope comes in. The different scopes for performing actions are listed below, but it should be noted that changing the scope on an action in this way will only apply the new scope to that action and not to subsequent actions in the chain. If you want to apply
- a change of action scope to multiple chained actions, then use the Apply to... action first. Essentially what you are telling GameMaker is the which instance should run the action. The default action scope is self, which means that once the object is created as an instance in the room, that instance will run the action code. However this isn't always what you want, and you may want some actions to affect other, or even all, instances in the room. This is where changing the action scope comes in. The different scopes for performing actions are listed below, but it should be noted that changing the scope on an action in this way will only apply the new scope to that action and not to subsequent actions in the chain. If you want to apply a change of action scope to multiple chained actions, then use the Apply to... action first. The other scope has two main functions, and the value it returns will depend on where and how you use it. In the Collision Event, other will return the unique instance ID value
- (a unique value that is used to distinguish individual instances of every object), so you can, for example, create a "bullet" instance and have a collision event with a "player" instance and in that use the other scope to remove hit points from the "player" object and then return to self scope to destroy the "bullet" instance. Outside of the collision event the other setting will behave as if it was set to noone unless it is being called from within a scoped block of actions. What this means is that if you change the
- scope of a group of actions to a specific object, then while those actions are being called, the other scope will return the instance ID of the instance that initially called the action group. For example, you could run
- an Apply to... action and then in the next code block set the scope to other to perform an action on the instance running the whole event block, and not the
- instance that is being scoped in the apply to code blocks. The image below gives an example: In the image, we are checking for a mouse press in the instance, and if one is detected we change scope using the Apply To... action. The next two action blocks are now being called from the "obj_Player" instance (if there is more than one then it will run for all of them) and so the object will change its sprite and then create an object at the other position,
- ie: the position of the object that is running the event and detected the mouse press. The other scope has two main functions, and the value it returns will depend on where and how you use it. In the Collision Event, other will return the instance handle, so you can, for example, create a "bullet" instance and have a collision event with a "player" instance and in that use the other scope to remove hit points from the "player" object and then return to self scope to destroy the "bullet" instance. Outside of the collision event the other setting will behave as if it was set to noone unless it is being called from within a scoped block of actions. What this means is that if you change the scope of a group of actions to a specific object, then while those actions are being called, the other scope will return the instance ID of the instance that initially called the action group. For example, you could run an Apply to... action and then in the next code block set the scope to other to perform an action on the instance running the whole event block, and not the instance that is being scoped in the apply to code blocks. The image below gives an example: In the image, we are checking for a mouse press in the instance, and if one is detected we change scope using the Apply To... action. The next two action blocks are now being called from the "obj_Player" instance (if there is more than one then it will run for all of them) and so the object will change its sprite and then create an object at the other position, ie: the position of the object that is running the event and detected the mouse press. When you scope an action for all, you are telling GameMaker to run that block for every single active instance within the current room. For example creating a Destroy Object Instance action
- and setting its scope to all will cause every instance in the room to disappear, no matter what object they have been created from. When you scope an action for all, you are telling GameMaker to run that block for every single active instance within the current room. For example creating a Destroy Object Instance action and setting its scope to all will cause every instance in the room to disappear, no matter what object they have been created from. An action can also be given an object as it's scope. What this means is that all instances of the given object will run that action at the same time it is called. So if you have 100 enemy instances in the room, for example, and
- you want to set them all to point towards a specific point. You'd call the Set Point Direction and set the action scope to the object "obj_Enemy" and when it
- is called, all instances of that object will change direction. An action can also be given an object as it's scope. What this means is that all instances of the given object will run that action at the same time it is called. So if you have 100 enemy instances in the room, for example, and you want to set them all to point towards a specific point. You'd call the Set Point Direction and set the action scope to the object "obj_Enemy" and when it is called, all instances of that object will change direction. The Expression input field is for you to input the ID of a specific instance that you want the action to work on. It can be the unique ID value assigned to an instance from the Room Editor or it can be the ID of an instance that you've stored
- in a variable (where the variable would be the input value) or it can even be an expression using code, as shown in the image below: In this case, an instance calls the Set Sprite from
- the instance created by the code given for the Expression. Note that in this case, the instance being created will run its Create Event first before the action is applied to it. The Expression input field is for you to input the ID of a specific instance that you want the action to work on. It can be the unique ID value assigned to an instance from the Room Editor or it can be the handle of an instance that you've stored in a variable (where the variable would be the input value) or it can even be an expression using code, as shown in the image below: In this case, an instance calls the Set Sprite from the instance created by the code given for the Expression. Note that in this case, the instance being created will run its Create Event first before the action is applied to it. With this function you can activate a layer that has been deactivated previously. You need to supply the layer ID, which can either be the name of the layer as written in the code editor (as a string) or the actual layer ID value as returned by the layer_create and all deactivated instances on that layer will activated once again. Note that if you have deactivated a layer that has persistent instances, you will need to reactivate the layer again with this function before changing room, otherwise any persistent instances will not be carried over and will be discarded. Note too that activation is not instantaneous, and an instance that has been activated in this way will not be considered to be active until the end of the event in which the function was called. With this function you can activate a layer that has been deactivated previously. You need to supply the layer ID, which can either be the name of the layer as written in the code editor (as a string) or the actual layer handle as returned by the layer_create and all deactivated instances on that layer will activated once again. Note that if you have deactivated a layer that has persistent instances, you will need to reactivate the layer again with this function before changing room, otherwise any persistent instances will not be carried over and will be discarded. Note too that activation is not instantaneous, and an instance that has been activated in this way will not be considered to be active until the end of the event in which the function was called. instance_activate_layer(layer_id); This function is used to create a new layer within the current room. You supply the depth that the new layer is to occupy and the function returns the unique layer ID handle that can then be used to access the layer in further functions. You can also supply an optional "name" argument, which will enable you to give the layer a specific name (as a string), and instead of using the layer ID to access the layer, you can use this name string instead, although it should be noted that using name strings will have a greater impact on performance than using just the ID value. If you do not specify the name of the layer, then the created layer will be assigned a name with the format "_layer_XXX", where "XXX" is a hex value used to give the layer a unique name. This function is used to create a new layer within the current room. You supply the depth that the new layer is to occupy and the function returns the layer handle that can then be used to access the layer in further functions. You can also supply an optional "name" argument, which will enable you to give the layer a specific name (as a string), and instead of using the layer ID to access the layer, you can use this name string instead, although it should be noted that using name strings will have a greater impact on performance than using just the ID value. If you do not specify the name of the layer, then the created layer will be assigned a name with the format "_layer_XXX", where "XXX" is a hex value used to give the layer a unique name. When giving a depth value, this will be higher the "further away" from the camera the layer is and lower the "closer" to the camera the layer is, so if you have three layers with depths -100, 0, 100, the layers will draw in the order 100, 0, -100, so that the "top" layer (ie, the closest to the camera view and so drawn over everything else) will be the layer with the -100 depth. The following image shows a schematic of how depth works for layers: It is worth noting that while you can assign more than one layer to a single depth, there is no way that you can guarantee that layers on the same depth will be drawn in any given order and as such it is best to assign only one layer to any given depth. Also note that the minimum and maximum layer depths are -16000 to 16000, and anything outside of those depths will not be rendered. If you require a depth outside of that range then you will need to use the function layer_force_draw_depth(). This opens an ini_file for reading and/writing. If the ini_file does not exist at the location you are checking, GameMaker may create one, but only if you write data to it. If you have only read information from the ini file, then the default values for the read function will be returned, but the ini file will not actually be created. This opens an ini file for reading and/writing. If the ini file does not exist at the location you are checking, GameMaker may create one, but only if you write data to it. If you have only read information from the ini file, then the default values for the read function will be returned, but the ini file will not actually be created. Please note that you can only have one ini file open at any one time and remember to use ini_close() once you're finished reading/writing from the .ini file as the information is not actually stored to disk until then (it is also stored in memory until the file is closed). This function adds one or more tag strings to any asset from The Asset Browser. You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset index value, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset handle, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: If the function succeeds in adding the tag(s) it will return true otherwise it will return false. var _a = array_create(3); This function gets the unique identifying index for a game asset from its name. If the asset is not found, the function will return a value of -1, otherwise it will return the unique index ID for the asset being checked. This ID can then be used in other functions as you would any other index value, like the sprite_index or the path_index, for example. Please note that although this function can be used to reference assets from strings (see example below), you should always make sure that the asset exists before using it otherwise you may get errors that will crash your game. This function gets the handle for a game asset from its name. If the asset is not found, the function will return a value of -1, otherwise it will return the handle for the asset being checked. This handle can then be used in other functions as you would any other handle, like sprite_index or path_index, for example. Please note that although this function can be used to reference assets from strings (see example below), you should always make sure that the asset exists before using it otherwise you may get errors that will crash your game. asset_get_index(name); This function retrieves all tags assigned to an asset from The Asset Browser. You supply either the asset name (as a string) or its asset index, and the function will return an array of tags for that asset. If no tags are found or there is an error (i.e.: the name string given doesn't exist) then the returned array will be empty. If you supply an asset index value, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: You supply either the asset name (as a string) or its asset index, and the function will return an array of tags for that asset. If no tags are found or there is an error (i.e.: the name string given doesn't exist) then the returned array will be empty. If you supply an asset handle, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: my_tags = asset_get_tags(object_get_name(object_index)); This function checks if one or more tag strings is assigned to any asset from The Asset Browser. You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset index value, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset handle, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: If the function succeeds and one or more of the tag(s) is present for the asset then it will return true otherwise it will return false. If you need to check for a precise match to any given tag or set of tags, then use the function asset_has_tags(). var _a = array_create(3); This function checks if one or more tag strings is assigned to the given asset from The Asset Browser. You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset index value, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset handle, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: If the function succeeds and all of the given tags are present for the asset then it will return true otherwise it will return false. If you need to check for any of a selection of tags rather than all tags, use the function asset_has_any_tag(). var _a = array_create(3); This function removes one or more tag strings to any asset from The Asset Browser. You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset index value, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: You supply either the asset name (as a string) or its asset index, as well as either a single tag string or an array where each item is a single tag string. If you supply an asset handle, then you will need to supply the optional asset type argument (a constant), as assets of different types can have the same index, even though they cannot have the same name. The available asset types are listed in the table below: If the function succeeds in removing the tag(s) it will return true otherwise it will return false. Boolean (whether the tags could be removed) Boolean (whether the tags could be removed) var _a = array_create(3); This function retrieves the names of all assets that have been assigned the given tag or tags. You supply either a single tag string or an Array, where each item in the array is a tag string. The function will return an array where each entry is the name (as a string) of the asset with the given tag. If you need the unique index for the asset, then you can use the function asset_get_index along with the returned name. If there are no assets with the given tag(s), or if there is an error (e.g.: the given tags don't exist), then an empty array will be returned. You supply either a single tag string or an Array, where each item in the array is a tag string. The function will return an array where each entry is the name (as a string) of the asset with the given tag. If you need the handle for the asset, then you can use the function asset_get_index along with the returned name. If there are no assets with the given tag(s), or if there is an error (e.g.: the given tags don't exist), then an empty array will be returned. tag_get_assets(tags); backgrounds = ds_list_create();buffer_write
+
+
+ Buffer Error Constant
+
+
+ Constant
+ Description
+ Value
+
+
+ buffer_error_general
+ A general buffer error.
+ -1
+
+
+ buffer_error_out_of_space
+ The buffer doesn't have enough space for the size of the type being written.
+ -2
+
+
+
+ buffer_error_invalid_type
+ Attempting to write an invalid type to a buffer. For example, submitting a string value for a buffer_u16 type or a buffer_f16 into a "fast" buffer that only takes buffer_u8 values.
+ -4
+ Syntax:
Syntax:
Returns:
- Example:
@@ -67,7 +99,7 @@ Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
- The_Game_Window.htm
+ The Game Window
Border & Caption
Dimensions & Position
@@ -88,7 +88,7 @@
Dimensions & Position
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
Applying Actions To Other Instances
Applying Actions To Other Instances
Applying Actions To Other Instances
© Copyright YoYo Games Ltd. 2021 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
instance_activate_layer
- Syntax:
Syntax:
@@ -58,7 +58,7 @@ layer_id
- Layer ID or String
- The layer name string (or ID value) to be used
+ Layer or String
+ The layer name string (or layer handle) to be used
Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
layer_create
- Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
ini_open
- Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
asset_add_tags
Syntax:
name_or_index
- String or Asset
- The name of the asset (a string) or its index value (an integer).
+ String or Asset
+ The name of the asset (a string) or its handle.
tags
- String or Array of Strings
+ String or Array of Strings
A single asset tag string or an array with various asset tags.
[asset_type]
- Asset Type Constant
- The type of asset to set the tags on, only used when supplying an index for the first argument.
+ Asset Type Constant
+ The type of asset to set the tags on, only used when supplying a handle for the first argument.
Returns:
-
+
Example:
@@ -68,7 +68,7 @@ Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
asset_get_index
- Syntax:
Syntax:
diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_tags.htm b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_tags.htm
index b2fb3e993..a12d4ce41 100644
--- a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_tags.htm
+++ b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_tags.htm
@@ -17,7 +17,7 @@
name
String
- The name of the game asset to get the index of (a string).
+ The name of the game asset to get the handle of (a string).
asset_get_tags
Syntax:
@@ -31,19 +31,19 @@ Syntax:
name_or_index
- String or Asset
- The name of the asset (a string) or its index.
+ String or Asset
+ The name of the asset (a string) or its handle.
[asset_type]
- Asset Type Constant
- The type of asset to get the tags for, only used when supplying an index for the first argument.
+ Asset Type Constant
+ The type of asset to get the tags for, only used when supplying a handle for the first argument.
Returns:
-
+
Example:
Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
asset_has_any_tag
Syntax:
name_or_index
- String or Asset
- The name of the asset (a string) or its index value (an integer).
+ String or Asset
+ The name of the asset (a string) or its handle.
tags
- String or Array of Strings
+ String or Array of Strings
A single asset tag string or an array with various asset tags.
[asset_type]
- Asset Type Constant
- The type of asset to check the tags for, only used when supplying an index for the first argument.
+ Asset Type Constant
+ The type of asset to check the tags for, only used when supplying a handle for the first argument.
Returns:
-
+
Example:
@@ -72,7 +72,7 @@ Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
asset_has_tags
Syntax:
@@ -33,24 +32,24 @@ Syntax:
name_or_index
- String or Asset
- The name of the asset (a string) or its index value (an integer).
+ String or Asset
+ The name of the asset (a string) or its handle.
tags
- String or Array of Strings
+ String or Array of Strings
A single asset tag string or an array with various asset tags.
[asset_type]
- Asset Type Constant
- The type of asset to check the tags for, only used when supplying an index for the first argument.
+ Asset Type Constant
+ The type of asset to check the tags for, only used when supplying a handle for the first argument.
Returns:
-
+
Example:
@@ -71,7 +70,7 @@ Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
asset_remove_tags
Syntax:
name_or_index
- String or Asset
- The name of the asset (a string) or its index value (an integer).
+ String or Asset
+ The name of the asset (a string) or its handle.
tags
- String or Array of Strings
+ String or Array of Strings
A single asset tag string or an array with various asset tags.
[asset_type]
- Asset Type Constant
- The type of asset to remove the tags from, only used when supplying an index for the first argument.
+ Asset Type Constant
+ The type of asset to remove the tags from, only used when supplying a handle for the first argument.
Returns:
- Example:
@@ -67,7 +67,7 @@ Example:
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+ © Copyright YoYo Games Ltd. 2024 All Rights Reserved
tag_get_assets
Syntax:
Syntax:
tags
- String or Array of Strings
+ String or Array of Strings
A single asset tag string or an array with various asset tags.
Returns:
-
+
Example:
@@ -49,7 +49,7 @@ Example:
ds_list_add(backgrounds, asset_get_index(_assets[i]));
}
}
The above code creates a list, then retrieves the names of all the assets with the tag "background". It loops through the array of names returned, checking to see if any of them are sprite assets, and if they are then the unique index value for the asset is added to the list for future use.
+The above code creates a list, then retrieves the names of all the assets with the tag "background". It loops through the array of names returned, checking to see if any of them are sprite assets, and if they are then the unique handle for the asset is added to the list for future use.
-
This function can be used to add a font to your game from a font file present in the Included Files. You can define the size of the font (in points), as well as whether the font should be bold or italic, and you can also define the range of characters to include. The function returns an index value that should be stored in a variable as this will be needed in all further code that refer to this font, or it will return -1 if the function fails for any reason.
+This function can be used to add a font to your game from a font file present in the Included Files. You can define the size of the font (in points), as well as whether the font should be bold or italic, and you can also define the range of characters to include. The function returns a handle that should be stored in a variable as this will be needed in all further code that refer to this font, or it will return -1 if the function fails for any reason.
Note that the font file must be either a *.ttf or *.otf file, which can also be useful for adding non-standard fonts like Asian or Arabic fonts.
If you include such a font in the Included Files, it must be licensed for distribution with the game.
On Windows, this function can also load fonts installed on the system, e.g. "Arial". However it is not recommended to rely on system fonts, as another machine running your game may not have the same fonts installed.
@@ -36,39 +36,39 @@
new_font = font_add("gamefont.ttf", 24, true, true, 32, 128);
@@ -82,7 +82,7 @@With this function you can activate a layer that has been deactivated previously. You need to supply the layer ID, which can either be the name of the layer as written in the code editor (as a string) or the actual layer handle as returned by the layer_create and all deactivated instances on that layer will activated once again. Note that if you have deactivated a layer that has persistent instances, you will need to reactivate the layer again with this function before changing room, otherwise any persistent instances will not be carried over and will be discarded. Note too that activation is not instantaneous, and an instance that has been activated in this way will not be considered to be active until the end of the event in which the function was called.
--
instance_activate_layer(layer_id);
-Argument | -Type | -Description | -
---|---|---|
layer_id | -Layer or String | -The layer name string (or layer handle) to be used | -
-
N/A
--
instance_activate_all();
- var _cam = view_camera[0];
- var _vx = camera_get_view_x(_cam);
- var _vy = camera_get_view_y(_cam);
- var _vw = camera_get_view_width(_cam);
- var _vh = camera_get_view_height(_cam);
- instance_deactivate_region(_vx - 64, _vy - 64, _vw + 128, _vh + 128, false, false);
- instance_activate_layer("Player_Layer");
-
The above code activates all instances within the room and then deactivates those that are outside of the limits of the current camera view, except for the instances on the layer "Player_Layer" which are re-activated again at the end.
--
-