Skip to content

Commit

Permalink
Merge pull request #168 from YoYoGames/develop.gurpreet
Browse files Browse the repository at this point in the history
docs(general): Objects vs Instances fix
  • Loading branch information
gurpreetsinghmatharoo authored Aug 28, 2024
2 parents ac4fab6 + d7a4dd9 commit 1e36e5a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3>Accessing Variables</h3>
<h3>Functions Taking Only Objects or Instances</h3>
<p>There are built-in GML functions that operate on either an <strong>object handle</strong> or an <strong>instance handle</strong>, depending on the function.</p>
<p style="text-align: left; ">Functions that only take an object handle usually return information on all of its instances, such as <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_number.htm">instance_number</a></span>, on the object itself, such as <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Objects/object_get_name.htm">object_get_name</a></span>, and on one particular instance of the object, such as <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_nearest.htm">instance_nearest</a></span> and <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_create_layer.htm">instance_create_layer</a></span> (in this case, creating a new one). Another example is the function <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_change.htm">instance_change</a></span> which operates on the current instance and changes it to use a different object (and hence use its events).</p>
<p>Functions that only operate on instances mostly do so without arguments, as they operate on the instance executing the code. For example, <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_change.htm">instance_change</a></span> as previously mentioned, <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_copy.htm">instance_copy</a></span><span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Movement_And_Collisions/Movement/motion_add.htm">motion_add</a></span> and various other functions will operate on the current instance. There are functions that operate on instances via arguments, but they also accept object handles and are covered below under <strong>Mixed Functions</strong>.</p>
<p>Functions that only operate on instances mostly do so without arguments, as they operate on the instance executing the code. For example, <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_change.htm">instance_change</a></span> as previously mentioned, <span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Asset_Management/Instances/instance_copy.htm">instance_copy</a></span><span class="inline3_func"><a data-xref="{title}" href="../GameMaker_Language/GML_Reference/Movement_And_Collisions/Movement/motion_add.htm">motion_add</a></span> and various other functions will operate on the current instance. There are functions that operate on instances via arguments, but they also accept object handles and are covered in the next section.</p>
<h3>Functions Taking Both Objects and Instances</h3>
<p>There are built-in GML functions that take both an <strong>instance handle</strong> and an <strong>object handle</strong>.</p>
<p>The difference in most use cases is simple: passing an instance handle only modifies that <strong>one instance</strong>, and passing an object handle modifies <strong>all instances</strong> of the given object.</p>
Expand Down

0 comments on commit 1e36e5a

Please sign in to comment.