• Gamemaker: How to populate your game with objects
Gamemaker: How to populate your game with objects

Here’s a quick overview of Objects in GameMaker: Studio, which are what make up the different parts of the game, such as the player, the enemy, the score display, and so on. Objects can also control the game through the different Events and Actions that you add to them.

1.Choose the green ball icon from the icon menu (see this figure).

Choose the green ball to create a new Object. The Object Properties window appears.

2.In the Name field, type a name for the Object.

The name can be as simple as obj_plane.

3.To assign a Sprite, click the drop-down icon from the Sprite section.

A list of available Sprites appears for you to choose from. Sprites provide a visual representation of the Object — you know, so that the player has a cool-looking ship to shoot the bad guys (and the bad guys have fearsome-looking ships).

4.Click the New button from the Sprite section to open the Sprite Properties window.

You can load a Sprite or create a new one through the Editor.

5.Select the Visible check box if you want the Object to be visible in the game.

This is optional.

6.Select the Solid check box so that GameMaker knows this is an Object that will likely collide with other Objects.

For example, say you have two balls in a Room and they collide. You would expect them to bounce off each other as if they were balls in real life. But if one of the balls is not Solid, then the one ball might appear to roll right through the other as if it were made of air.

7.Select the Persistent check box for the Object to carry over from Room to Room.

The Object is not destroyed even if the player leaves one Room and enters another. The only way to destroy a Persistent Object is to do so explicitly through Events and Actions.

8.Select the Uses Physics check box to create a physics world.

This is optional.

9.In the Depth field, enter a numerical value (such as 10,000) to determine which layer of the Room you want the Object to reside at.

The Depth field enables you to place Objects over other Objects.

10.To assign a parent to the Object, click the drop-down icon (see this figure), and select an Object.

When you make a child Object, that Object inherits the properties of the parent Object.

11.To assign a Mask to the Object, click the drop-down icon and select the Sprite with the Mask you want to use.

If you don’t do this, GameMaker uses the Mask of the Sprite you assigned to the Object.

12.Click the Add Event button to select an Event to add to the Events section.

This is optional.

13.Drag and drop Actions from the tab on the right to the Actions section.

 

When you finish creating your Objects, you’re ready to place the Objects in the Room, so that you can create Instances of those Objects within the game. You may have a single Object that represents a bad guy, but you can create several Instances of that one Object within the game; in that way, you can create many of the same bad guy to attack the player.