Skip to content

Commit

Permalink
docs(general): game_restart() does not clear out time sources created…
Browse files Browse the repository at this point in the history
… by call_later()

YoYoGames/GameMaker-Bugs#7403

* Added a line  to mention that  all time sources created by call_later are destroyed upon restarting the game.
* Other small updates to page
  • Loading branch information
YYBartT committed Oct 2, 2024
1 parent 1db1f47 commit cbfbbb7
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>game_restart</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<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" />
Expand All @@ -15,38 +15,41 @@
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">game_restart</span></h1>
<p>With this function you can restart the game. This is essentially the same as running the game for the first time and so the <a href="../../../The_Asset_Editors/Object_Properties/Other_Events.htm">Game Start Event</a> will be triggered, <i>as well as</i> the <a href="../../../The_Asset_Editors/Object_Properties/Other_Events.htm">Game End Event</a>.</p>
<p>This function restarts the game.</p>
<p>Restarting the game is essentially the same as running it for the first time and so the <a href="../../../The_Asset_Editors/Object_Properties/Other_Events.htm">Game Start Event</a> will be triggered <i>as well as</i> the <a href="../../../The_Asset_Editors/Object_Properties/Other_Events.htm">Game End Event</a>.</p>
<p><span>All time sources created by <span class="inline3_func"><a data-xref="{title}" href="../Time_Sources/call_later.htm">call_later</a></span> are destroyed upon restarting the game.</span></p>
<div data-conref="../../../assets/snippets/changing_room_stops_instance_creation.hts"> </div>
<p>It should be noted that certain things will <b>not</b> be reset when this function is called:</p>
<ul class="colour">
<li>Global variables will not be re-initialised unless explicitly coded as such - for example, the built-in global variable <span class="inline">score</span> will not start at zero after a game restart if it has been modified in the game already.</li>
<li>The GPU state will not be changed (so if you have set the draw colour or alpha, for example, it will remain at the changed value).</li>
<li>The game speed will remain at whatever you set it in your game code (if you changed it this change will be perpetuated).</li>
<li>Any asset from the Asset Browser that has been changed at run time within the game - for example if you change the origin for a sprite resource or shift the position of a path resource - will <i>not</i> be reset.</li>
<li>Dynamic resources like buffers, surfaces, data-structures or imported sprites will also not be cleaned up or removed (although you may lose references to them, so take care when using this function to either use global references for the dynamic resource, or to clean them up before the function is called).</li>
<br />
<br />

<li><a data-xref="{title}" href="../../GML_Overview/Variables/Global_Variables.htm">Global Variables</a> will not be re-initialised unless explicitly coded as such - for example, the built-in global variable <span class="inline2"><a data-xref="{title}" href="../../GML_Overview/Variables/Builtin_Global_Variables/score.htm">score</a></span> will not start at zero after a game restart if it has been modified in the game already.</li>
<li>The <a href="../Drawing/GPU_Control/gpu_get_state.htm" title="gpu_get_state()">GPU state</a> will not be changed (so if you have set the draw colour or alpha, for example, it will remain at the changed value).</li>
<li>The <a href="game_get_speed.htm" title="game_get_speed()">game speed</a> will remain at whatever you set it in your game code (if you changed it this change will be perpetuated).</li>
<li>Any asset from the Asset Browser that has been changed at run time within the game - for example if you change the origin of a sprite asset or shift the position of a path asset - will <i>not</i> be reset.</li>
<li>Dynamic resources like buffers, surfaces, data structures or imported sprites will also not be cleaned up or removed (although you may lose references to them, so take care when using this function to either use global references for the dynamic resource, or to clean them up before the function is called).</li>
</ul>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">game_restart</span>();</p>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Void">N/A</span></p>
<p> </p>
<h4>Example:</h4>
<p class="code">if keyboard_check_pressed(ord(&quot;R&quot;)) <span data-field="title" data-format="default">game_restart</span>();</p>
<p>This would restart the game when the player presses the &quot;R&quot; key.</p>
<p class="code">if keyboard_check_pressed(ord(&quot;R&quot;))<br />
{<br />
    <span data-field="title" data-format="default">game_restart</span>();<br />
}</p>
<p>This code restarts the game when the player presses the &quot;R&quot; key.</p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="General_Game_Control.htm">General Game Control</a></div>
<div style="float:left">Back: <a data-xref="{title}" href="General_Game_Control.htm">General Game Control</a></div>
<div style="float:right">Next: <a data-xref="{title}" href="game_change.htm">game_change</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
game_restart
Expand Down

0 comments on commit cbfbbb7

Please sign in to comment.