Skip to content

Commit

Permalink
Merge pull request #221 from YoYoGames/develop.gurpreet
Browse files Browse the repository at this point in the history
Mark SVG as beta, and package manager as non-beta
  • Loading branch information
gurpreetsinghmatharoo authored Nov 27, 2024
2 parents 5a4c0bd + 8e3f441 commit 157bb0f
Show file tree
Hide file tree
Showing 151 changed files with 7,731 additions and 8,008 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>delete</h1>
<p>The <span class="inline">delete</span> operator is used to <strong>de-reference</strong> a <a href="../Structs.htm">struct</a>, and has the following syntax:</p>
<p>The <span class="inline">delete</span> operator is used to <strong>de-reference</strong> a <a href="../Structs.htm">struct</a> and has the following syntax:</p>
<p class="code">delete &lt;variable&gt;;</p>
<p>What this means is that you call the delete operator along with the variable that holds a struct and it will remove the specific <em>reference </em>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 <a class="glossterm" data-glossterm="garbage collector" href="#">garbage collector</a> will remove the struct from memory in a following <a class="glossterm" data-glossterm="iteration" href="#">iteration</a>, typically at the very start of the next step.</p>
<p>You call the delete operator along with the variable that holds a struct and it will remove the specific <em>reference </em>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 <a class="glossterm" data-glossterm="garbage collector" href="#">garbage collector</a> will remove the struct from memory in its next <a class="glossterm" data-glossterm="iteration" href="#">iteration</a>.</p>
<p class="note"><span data-conref="../../../assets/snippets/Tag_note.hts"> </span> <span class="inline">delete</span> can only be used along with variables, and <i>not</i> expressions.</p>
<p>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.</p>
<p>The following example shows a struct being created - for example in the Create Event of an instance:</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h3>Accessing Struct Variables</h3>
<p>and writing: </p>
<p class="code">mystruct[$ &quot;x&quot;] = 200;</p>
<p>If you need to use strings to access a struct variable, it is faster to <a href="../GML_Reference/Variable_Functions/variable_get_hash.htm">get its hash</a> and use that in <a href="../GML_Reference/Variable_Functions/struct_get_from_hash.htm">read</a>/<a href="../GML_Reference/Variable_Functions/struct_set_from_hash.htm">write</a> to the variable.</p>
<p>When a struct is no longer required it can be removed from memory using the <a href="Language_Features/delete.htm"><span class="inline2">delete</span></a> operator, which flags the struct as being able to be garbage collected. This is not strictly required as the <a class="glossterm" data-glossterm="garbage collector" href="#">garbage collector</a> will do this automatically if the struct is no longer referenced in your code, but using <span class="inline2">delete</span> prioritises the referenced struct for garbage collection (for example, call <span class="inline2"><a data-xref="{title}" href="Language_Features/delete.htm">delete</a></span> in the <a href="../../The_Asset_Editors/Object_Properties/Object_Events.htm">Clean Up event</a> 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 <span class="inline2">undefined</span> has the same effect.</p>
<p>When a struct is no longer required it can be removed from memory using the <a href="Language_Features/delete.htm"><span class="inline2">delete</span></a> operator, which flags the struct as being able to be garbage collected. This is not strictly required as the <a class="glossterm" data-glossterm="garbage collector" href="#">garbage collector</a> will do this automatically if the struct is no longer referenced in your code, but using <span class="inline2">delete</span> prioritises the referenced struct for garbage collection (for example, call <span class="inline2"><a data-xref="{title}" href="Language_Features/delete.htm">delete</a></span> in the <a href="../../The_Asset_Editors/Object_Properties/Object_Events.htm">Clean Up event</a> of an instance to explicitly tell the garbage collector that an instance scope struct is to be deleted as soon as possible).</p>
<p>Here is an example:</p>
<p class="code">// Create event<br />
mystruct =<br />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>depth</title>
<meta name="generator" content="Adobe RoboHelp 2022"/>
<link rel="stylesheet" href="../../../../../assets/css/default.css" type="text/css"/>
<script src="../../../../../assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="Mark Alexander"/>
<meta name="topic-comment" content="Page outlining the variable depth"/>
<meta name="rh-index-keywords" content="depth"/>
<meta name="search-keywords" content="depth"/>
</head>
<body><!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">depth</span></h1>
<p>When you create an object you can assign it an initial <i>depth</i> 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 <a href="layer.htm">layers</a>, 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 &quot;temporary layer&quot; 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).</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_important.hts"> </span> When you modify the <span class="inline2"><span data-field="title" data-format="default">depth</span></span> <font face="menlo, consolas, monospace"><b> </b></font>variable and <span data-keyref="GameMaker Name">GameMaker</span> manages the layers, the built-in <span class="inline2"><span style="font-size:1px;"><a href="layer.htm"><span class="inline">layer</span></a></span></span> variable will return -1 and not the layer handle, since managed layers cannot be manipulated through code. </p>
<div data-conref="../../../../../assets/snippets/Note_Depth_Values_Are_Approximate.hts"> </div>
<p>In <span data-keyref="GameMaker Name">GameMaker</span> the lower the depth value for an instance, the &quot;closer to the camera&quot; that instance will be drawn, while a higher depth value means that the instance will be drawn &quot;further away from the camera&quot;, i.e: -1000 is drawn on top of -100, which is drawn on top of 0, and so on.</p>
<p><img alt="Depth sorting example image" class="center" src="../../../../../assets/Images/Scripting_Reference/GML/Reference/Instances/depth_image.png"/>Note that instances that have the <b>same</b> depth may be drawn <b>above <i>or</i> below one another</b> regardless of how it appears in <a data-xref="{title}" href="../../../../../The_Asset_Editors/Rooms.htm">The Room Editor</a>. 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.</p>
<p>Also note that there is a minimum (<span data-keyref="Const_Depth_Min">-16000</span>) and maximum (<span data-keyref="Const_Depth_Max">16000</span>) depth value outside of which instances will not be drawn, although they will still exist and process events.</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_important.hts"> </span> 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&#39;re drawing might not be drawn.</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_note.hts"> </span> You <b>cannot</b> 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 <span class="inline3_func"><a data-xref="{title}" href="../../../Drawing/GPU_Control/gpu_set_depth.htm">gpu_set_depth</a></span>.</p>
<p>Keep in mind that modifying the depth of an instance may change which <a href="../../../../../The_Asset_Editors/Room_Properties/Filters_and_Effects.htm">Filters &amp; Effects</a> are applied on it, as changing the depth to be lower than an FX layer&#39;s depth will no longer apply its effect on the instance.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">depth</span></p>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Real"><a href="../../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span> (single precision floating point value)</p>
<p> </p>
<h4>Example:</h4>
<p class="code">if (y != yprevious)
<br/>
{
<br/>
depth = -y;
<br/>
}</p>
<p>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.</p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="Instance_Variables.htm">Instance Variables</a></div>
<div style="float:right">Next: <a href="layer.htm">layer</a></div>
</div>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>depth</title>
<meta name="generator" content="Adobe RoboHelp 2022" />
<link rel="stylesheet" href="../../../../../assets/css/default.css" type="text/css" />
<script src="../../../../../assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="Mark Alexander" />
<meta name="topic-comment" content="Page outlining the variable depth" />
<meta name="rh-index-keywords" content="depth" />
<meta name="search-keywords" content="depth" />
</head>
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">depth</span></h1>
<p>When you create an object you can assign it an initial <i>depth</i> 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 <a href="layer.htm">layers</a>, 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 &quot;temporary layer&quot; 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).</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_important.hts"> </span> When you modify the <span class="inline2"><span data-field="title" data-format="default">depth</span></span>
<font face="menlo, consolas, monospace"><b> </b></font>variable and <span data-keyref="GameMaker Name">GameMaker</span> manages the layers, the built-in <span class="inline2"><span style="font-size:1px;"><a href="layer.htm"><span class="inline">layer</span></a></span></span> variable will return -1 and not the layer handle, since managed layers cannot be manipulated through code.
</p>
<div data-conref="../../../../../assets/snippets/Note_Depth_Values_Are_Approximate.hts"> </div>
<p>In <span data-keyref="GameMaker Name">GameMaker</span> the lower the depth value for an instance, the &quot;closer to the camera&quot; that instance will be drawn, while a higher depth value means that the instance will be drawn &quot;further away from the camera&quot;, i.e: -1000 is drawn on top of -100, which is drawn on top of 0, and so on.</p>
<p><img alt="Depth sorting example image" class="center" src="../../../../../assets/Images/Scripting_Reference/GML/Reference/Instances/depth_image.png" />Note that instances that have the <b>same</b> depth may be drawn <b>above <i>or</i> below one another</b> regardless of how it appears in <a data-xref="{title}" href="../../../../../The_Asset_Editors/Rooms.htm">The Room Editor</a>. 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.</p>
<p>Also note that there is a minimum (<span data-keyref="Const_Depth_Min">-16000</span>) and maximum (<span data-keyref="Const_Depth_Max">16000</span>) depth value outside of which instances will not be drawn, although they will still exist and process events.</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_important.hts"> </span> 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&#39;re drawing might not be drawn.</p>
<p class="note"><span data-conref="../../../../../assets/snippets/Tag_note.hts"> </span> You <b>cannot</b> 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 <span class="inline3_func"><a data-xref="{title}" href="../../../Drawing/GPU_Control/gpu_set_depth.htm">gpu_set_depth</a></span>.</p>
<p>Keep in mind that modifying the depth of an instance may change which <a href="../../../../../The_Asset_Editors/Room_Properties/Filters_and_Effects.htm">Filters &amp; Effects</a> are applied on it, as changing the depth to be lower than an FX layer&#39;s depth will no longer apply its effect on the instance.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">depth</span></p>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Real"><a href="../../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span> (single precision floating point value)</p>
<p> </p>
<h4>Example:</h4>
<p class="code">if (y != yprevious)<br />
{<br />
    depth = -y;<br />
}</p>
<p>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.</p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="Instance_Variables.htm">Instance Variables</a></div>
<div style="float:right">Next: <a href="layer.htm">layer</a></div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
depth
--><!-- TAGS
-->
<!-- TAGS
depth
--></body>
-->
</body>
</html>
Loading

0 comments on commit 157bb0f

Please sign in to comment.