The Object Editor

The Object EditorObjects are the resource that we use to control aspects of a game and to do specific things. Most of the time they have a sprite associated with them so that you see them in the game rooms, but sometimes they are used as a "behind the scenes" controller to do things related to the user or for timing, etc... They can be given behaviours and they can react to certain events as well as to each other, and most of the things you see in a game are based on objects and their interactions. Now, we say "based on" because you don't actually place objects directly into the game rooms, but rather you place instances of these objects which are basically copies (or clones if you prefer) of the object resource. This is a very important thing to remember as instances and objects are not the same thing and each have their own set of functions that can affect them.

To clarify this, think of a game made with GameMaker. All the characters, monsters, balls, walls, etc. are all objects you create in The Asset Browser. You then drag the object into a room in The Room Editor to create an instance copied from the basic object template. The instance in the room can then be changed in the editor itself or through code, so that it can be scaled, or coloured, or have other details modified from the "base" object. So when we talk about something affecting or changing an instance, we mean it affects that one particular copy of an object in a room. Only that single instance is being affected while all the rest are not. But, when we talk about affecting or changing an object, we mean that we are modifying the object in the Asset Browser and anything we do to it will be reflected in all the instances created from that point on too. So, the object is the template for the instance, and the instance is what we place in a room to make our game.

To create an object in your game, you can right click RMB Icon on the Asset Browser and click the Create Object option. This will open the window pictured at the top of this page with the following sections:

DetailsDetails

Here you can give your object a name. This name should never contain spaces nor unauthorized characters (only alpha-numeric characters and the underbar "_" are allowed) and should be short but memorable so that you can easily identify resources later when you may have many of them. For example many people use a prefix or a suffix to identify the differences between resources, like "obj_Ship" or "Ship_obj".

Next you can choose the sprite for the object should you wish it to have one. Click with the left mouse button LMB Icon on the sprite box and the Asset Explorer will appear with a list of all the available sprites from the Asset Browser:

The Asset ExplorerYou can then select the one you want to use for the object. With a sprite assigned to the object you can click the Edit Sprite button Edit Sprite Icon to change the sprite properties, or - if you do not have a sprite for the object but wish to create one - you can click the Add Sprite button Add Sprite Icon to create a new sprite asset and assign that.

You can also edit the sprite asset image that has been assigned by clicking the Edit Image button Edit Image Icon. This opens the image in The Image Editor if no external editor is set or in the external editor for the given sprite type, if it's provided in the Path Preferences.

 

Collision MaskCollision Mask

Beneath the sprite assignment area you have a button for choosing a specific Collision Mask. By default an object will generate collision properties based off of the sprite assigned to it, but there are cases whereby you may want collisions to be based off a different shape from a different sprite. For example, you may have a top down game where the main sprite has a rectangular collision mask, but to make collisions smoother a circular mask may be better. In these cases you can click the Collision Mask button and select another sprite resource, so now instances of the object will draw the assigned sprite, but base collisions off of the mask sprite. You can find out more information about collision masks from the page on the Sprite Editor.

 

PropertiesProperties

Here you are presented with the following options for your object:

Persistence And Room LayersPersistence And Room Layers  

When you create an instance with persistence enabled in a room, it will be assigned a layer or a depth (depending on which function you used to create the instance of the object). When the room is changed, and if the following room does not have a layer with the same name or depth as the one assigned, then a new layer will be created for the instance that is persisting across the rooms. If you gave a named layer when the instance was created, then the new layer will also be named the same as original layer, while if you assigned a depth to the instance then the new layer will be named "_layer_XXX", where "XXX" is a hex value used to give the layer a unique name. These layers will be removed from the room on Room End.

Another thing to note about layers and persistent instances is that if you have assigned the instance a named layer on creation, and there is another layer in the following rooms with the same name, then the persisted instance will be assigned to the layer with the same name regardless of the depth of the layer.

Finally, if a persisted instance moves to a room with a layer at the same depth as the instance was created on, it will not be assigned to this layer, but instead a new layer will be created at the same depth (following the naming convention explained above).

Persistence And EventsPersistence And Events

As mentioned previously, a persistent object will only run its Create Event once, but it will also have its Game Start, Game End, Room Start and Room End events triggered at the appropriate times. However if you restart the game (with, for example, the game_restart() function) all persistent objects will be removed and only exist when created again by the game.

Also note that if you deactivate a persistent object, it will no longer pass from one room to another unless re-activated before the Room End event is triggered. Re-activation requires a full game step to occur, so using the actual Room End event for this does not work, as it doesn't give the game a full step to reactivate the object, so you need to keep this in mind when using deactivation along with persistent objects and plan your code accordingly.

 

The last part of the Object Editor is taken up with the different object Options, each of which is discussed on its on page, linked below: