<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<script type="text/javascript" language="JavaScript">
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = reDo;
}
onerror = null;
</script>
<style type="text/css">
< !-- div.WebHelpPopupMenu {
position: absolute;
left: 0px;
top: 0px;
z-index: 4;
visibility: hidden;
}
p.WebHelpNavBar {
text-align: right;
}
-->
</style>
<script type="text/javascript">
gRootRelPath = "../../../..";
gCommonRootRelPath = "../../../..";
gTopicId = "9.2.2.12";
<script type="text/javascript" src="../../../../template/scripts/rh.min.js"></script>
<script type="text/javascript" src="../../../../template/scripts/common.min.js"></script>
<script type="text/javascript" src="../../../../template/scripts/topic.min.js"></script>
<script type="text/javascript" src="../../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../../whxdata/projectsettings.js"></script>
<link rel="stylesheet" type="text/css" href="../../../../template/styles/topic.min.css"/>
<link rel="stylesheet" type="text/css" href="../../../../template/Charcoal_Grey/topicheader.css"/>
<meta name="topic-status" content="Draft"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Objects</title>
<meta name="generator" content="Adobe RoboHelp 2019"/>
<link rel="stylesheet" href="../../../../assets/css/default.css" type="text/css"/>
<meta name="rh-authors" content="Mark Alexander"/>
<meta name="topic-comment" content="Page outlining the different functions and variables associated with Objects"/>
<meta name="rh-index-keywords" content=""/>
<meta name="search-keywords" content="Objects"/>
</head>
<body>
<div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
<div class="logo">
</div>
<div class="nav">
<div class="title" title="Objects">
<span>Objects</span>
</div>
<div class="gotohome" title="Click here to see this page in full context">
<span>Click here to see this page in full context</span>
</div>
</div>
</div>
<div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>
<h1>Objects</h1>
<p>In GameMaker Studio 2 you have objects and you have instances. Objects are essentially the base template for an instance, and as such are <i>never</i> present in a room directly... only <i>instances</i> of the object are placed in the room. This
means that if you want to change something for all instances you are going to create, then you can do it by changing the <i>object</i>.</p>
<p class="note"><b>IMPORTANT!</b> Changing anything about an object will <b>not</b> change any instances currently present in the room, only those that are created after the change.</p>
<p>You can also access information about a base object and use it to dictate behaviors or changes in the game. For example, you can do a check for a parent object ID, and in the following code if an instance with that parent is found you can then check
its <tt>object_index</tt> to decide what should be done.</p>
<p>GameMaker Studio 2 gives you a number of functions that permit you to get various details about an object. Note, an object is <i>not</i> an instance (an in-game entity), it is purely a resource from which all instances are created. This means
that the return values of these functions may be different to the actual values shown by instances in the room, as once an instance is created it can be changed through code and DnD™ actions.</p>
<p> </p>
<ul class="colour">
<li><a href="object_index.htm">object_index</a></li>
<li><a href="object_exists.htm">object_exists</a></li>
<li><a href="object_get_name.htm">object_get_name</a></li>
<li><a href="object_get_mask.htm">object_get_mask</a></li>
<li><a href="object_get_parent.htm">object_get_parent</a></li>
<li><a href="object_get_persistent.htm">object_get_persistent</a></li>
<li><a href="object_get_solid.htm">object_get_solid</a></li>
<li><a href="object_get_sprite.htm">object_get_sprite</a></li>
<li><a href="object_get_visible.htm">object_get_visible</a></li>
<li><a href="object_get_physics.htm">object_get_physics</a></li>
<li><a href="object_is_ancestor.htm">object_is_ancestor</a></li>
</ul>
<p> </p>
<p>There are also a number of functions that permit you set the properties for an object. It should be noted that any instances of this object that already exist in the room <i>may not be affected by these functions</i>, but all new instances of this object
created in the room will be, so it is recommend that you never change an objects properties when instances of that object are present in the current room.</p>
<p> </p>
<ul class="colour">
<li><a href="object_set_mask.htm">object_set_mask</a></li>
<li><a href="object_set_persistent.htm">object_set_persistent</a></li>
<li><a href="object_set_solid.htm">object_set_solid</a></li>
<li><a href="object_set_sprite.htm">object_set_sprite</a></li>
<li><a href="object_set_visible.htm">object_set_visible</a></li>
</ul>
<p> </p>
<p>You can also use certain functions to generate events from code from within a specific instance or object. These functions can be very useful, especially when dealing with <a href="../../../../The_Asset_Editors/Object_Properties/Parent_Objects.htm">Parents and Children</a>,
and are outlined in the following section:</p>
<ul class="colour">
<li><a href="Object_Events/Generating_Object_Events.htm">Generating Object Events</a></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="../Asset_Management.htm">Asset Management</a></div>
<div style="float:right">Next: <a href="../Instances/Instances.htm">Instances</a></div>
</div>
</div>
<h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
</div>
</body></html>