Object (Game Maker)

Objects are are core of object oriented programming. Just about anything in your game that can interact with something will be an object. Your main character, enemies, level walls, etc will probably all be objects. Actually, that's not quite true.

An object is actually a definition of a type of something. You use it to create instance of the object in the game. To understand this, let's make an analogy. An object is a cookie cutter. It contains the shape and size of the cookie. You can use a cookie cutter to make as many cookies as you want.

It is the same with objects and instances: if you define an alien ship as an object, lets say, with the name obj_alien_ship. Then, whenever you need an alien ship, you create an instance of it. If you need more than one alien ship, you can create as many instances of the object obj_alien_ship as you want. All of the instances will have the same qualities as the object it was created from.

Parent Object

Since GML is an object based language, objects can inherit code and properties from their parents. This is a very powerful and time saving feature of Game Maker. If you make a parent object for all enemies, the Collision event for the parent object will apply to all children of the parent object.

Object Naming Conventions

Objects are typically named by programmers to help remind them what they are, below is a list of prefixes used in these naming conventions :

  • obj_ (obj_player) - ordinary object
  • con_ or cont_ (cont_scroller) - controller object
  • par_ (par_wall) - parent object
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.