diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Language_Features/delete.htm b/Manual/contents/GameMaker_Language/GML_Overview/Language_Features/delete.htm index a1e78c9d2..482d3ccc7 100644 --- a/Manual/contents/GameMaker_Language/GML_Overview/Language_Features/delete.htm +++ b/Manual/contents/GameMaker_Language/GML_Overview/Language_Features/delete.htm @@ -15,9 +15,9 @@

delete

-

The delete operator is used to de-reference a struct, and has the following syntax:

+

The delete operator is used to de-reference a struct and has the following syntax:

delete <variable>;

-

What this means is that you call the delete operator along with the variable that holds a struct and it will remove the specific reference to the struct stored in the given variable (a reference is simply a value that points to the memory area that is storing the struct and its contents). If this reference was the last reference to the struct in your game, then the garbage collector will remove the struct from memory in a following iteration, typically at the very start of the next step.

+

You call the delete operator along with the variable that holds a struct and it will remove the specific reference to the struct stored in the given variable (a reference is simply a value that points to the memory area that is storing the struct and its contents). If this reference was the last reference to the struct in your game, then the garbage collector will remove the struct from memory in its next iteration.

 delete can only be used along with variables, and not expressions.

By default, structs with no further references in code will be garbage collected automatically in the steps following their use, but it is good practice to use this operator to flag them explicitly for the garbage collector to remove from memory at the very start of the following step, freeing the memory quickly and more efficiently.

The following example shows a struct being created - for example in the Create Event of an instance:

diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Structs.htm b/Manual/contents/GameMaker_Language/GML_Overview/Structs.htm index 997e00b79..be8d61921 100644 --- a/Manual/contents/GameMaker_Language/GML_Overview/Structs.htm +++ b/Manual/contents/GameMaker_Language/GML_Overview/Structs.htm @@ -137,7 +137,7 @@

Accessing Struct Variables

and writing: 

mystruct[$ "x"] = 200;

If you need to use strings to access a struct variable, it is faster to get its hash and use that in read/write to the variable.

-

When a struct is no longer required it can be removed from memory using the delete operator, which flags the struct as being able to be garbage collected. This is not strictly required as the garbage collector will do this automatically if the struct is no longer referenced in your code, but using delete prioritises the referenced struct for garbage collection (for example, call delete in the Clean Up event of an instance to explicitly tell the garbage collector that an instance scope struct is to be deleted as soon as possible). Setting a struct variable to undefined has the same effect.

+

When a struct is no longer required it can be removed from memory using the delete operator, which flags the struct as being able to be garbage collected. This is not strictly required as the garbage collector will do this automatically if the struct is no longer referenced in your code, but using delete prioritises the referenced struct for garbage collection (for example, call delete in the Clean Up event of an instance to explicitly tell the garbage collector that an instance scope struct is to be deleted as soon as possible).

Here is an example:

// Create event
mystruct =
diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/depth.htm b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/depth.htm index 666059a8b..6c9b5a5b2 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/depth.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/depth.htm @@ -1,58 +1,60 @@ - + - - - depth - - - - - - - - - -

depth

-

When you create an object you can assign it an initial depth which defines how the instances of that object will be drawn in the room when the game is being played and this variable can be used to get and to change that depth value while the game is running. You would normally not need to use this variable as you should be setting instances to be added to discreet layers, which in turn are set to a specific depth, but it may be that you want to change the depth of an instance using this value, in which case a "temporary layer" will be created specifically for the instance at the given depth. Note that when no instances are on the same depth then this temporary layer will be removed from memory (unlike regular layers which will remain even if they have nothing on them).

-

When you modify the depth variable and GameMaker manages the layers, the built-in layer variable will return -1 and not the layer handle, since managed layers cannot be manipulated through code.

-
-

In GameMaker the lower the depth value for an instance, the "closer to the camera" that instance will be drawn, while a higher depth value means that the instance will be drawn "further away from the camera", i.e: -1000 is drawn on top of -100, which is drawn on top of 0, and so on.

-

Depth sorting example imageNote that instances that have the same depth may be drawn above or below one another regardless of how it appears in The Room Editor. This is not guaranteed to be consistent between target platforms as it will depend on the graphics device in use. If you want to guarantee that something is drawn over or under everything else, you should always set the depth (or layer) explicitly.

-

Also note that there is a minimum (-16000) and maximum (16000) depth value outside of which instances will not be drawn, although they will still exist and process events.

-

The minimum and maximum depth values are approximate. As a result, when you set the draw depth to a value close to these limits, what you're drawing might not be drawn.

-

You cannot set the depth of an instance in its Draw event (all other events are fine). You can, however, set the depth at which to draw things in the Draw event using gpu_set_depth.

-

Keep in mind that modifying the depth of an instance may change which Filters & Effects are applied on it, as changing the depth to be lower than an FX layer's depth will no longer apply its effect on the instance.

-

-

Syntax:

-

depth

-

-

Returns:

-

Real (single precision floating point value)

-

-

Example:

-

if (y != yprevious) -
- { -
- depth = -y; -
- }

-

The above code will check to see if the y position has changed and if it has then the depth will also be set to correspond to it.

-

-

-