Tuesday, June 5, 2012

Multiple Parenting Theories In Game Maker

In Game Maker, there is a system for objects called "parenting". Each object is allowed one parent. The "child" object may inherit events from the parent object. Also, the child objects are treated like their parents, but their parents are not treated as their children.

So, my goal in this blog post is to create a way for a child object to have multiple parent objects by GML(Game Maker Language) code. This, if successful, will be advantageous for many things while programming, including much more flexibility.

The Father-Mother Theory
The primary, default parent object of the child will be called the "father" object. A child can also have a secondary parent called the "mother". When a child executes events, it does so it executes the father's events first, then the mother's.


Pros: event handling is seamless
Cons: mother parent does not affect instance finding functions

Dual Object/Overlay Theory
Each child has a primary parent, and also a secondary parent. It creates the secondary parent as an invisible overlay instance. This helps so that the instance finding functions can still find both somewhat seamlessly.

Pros: instance finding functions(howbeit modified)
Cons: event handling complicated between two objects, double the memory needed

Combined Theories
Simply, combining both theories.

Pros: instance finding functions, event inheritance
Cons: event handling may conflict between the two objects, double memory needed



Here is the file:
http://gamejolt.com/open-source/games/other/multi-parenting-for-gm/8092/

No comments:

Post a Comment