Okay in this video, we are going to look at how parent objects are used in Game Maker. Here I have a basic game and what is involves is, I am just going to click on ghost and as I click on ghost I earn points, there are three types of ghosts and depending on how, fast they go you get more points and they are created at set intervals.
I am going to look at this game, I have Red Monsters, Blue Monster and blink Green Monsters and if you look for each of them I create and they move in a direction, however they move with different speeds, on mouse clicks they destroy and their scores increase depending on how fast they go. Now I also want to have it whenever they go outside of the room they destroy themselves and they decrease the score by two, to allow these actions were similar to create in a mouse click, the outside room is identical and I am going to save myself some time by using the parent object and what a parent object is, is it has behaviors that I am going to apply to each of these guys, they are still at their individual behaviors just like all kids have individual characteristics, but the parent object will also get every one the same.
So let's look at how I am going to do that, I want to make myself an object and I am going to call it ParentGhost, I am not going to just play with it and if I remember the events that they all had in common was when they go outside of the room they destroy themselves and they decrease the score by two. So let me go ahead and add those in Outside the Room, Destroy Itself and also it goes outside of the room, I want to set the score to negative two, so it will decrease, I will make sure I click Relative.
Now I am going to go back each of the monsters and like I said they have their own behaviors here, however I am also going to give them the parent behavior, and I do that by clicking on Parent that's like in the parent ghost and I am going to do that for each one of them parent, parent ghost, parent ghost, the Blue Monster, parent, parent ghost. So what that has just done as applied, these event and actions to each one of those.
So now when I run my game, each of the ghost still maintain their own behaviors, but I have now added those additional ones, so as you can see I am getting some score, however when red one goes away, my score went down seven, I lost some points there on those guys. As you can see I am losing points because they have the parent behavior looks like both of these go outside we should lose points on each one of them even though they are different colors and there we go, we start to lose some points.
So hopefully this short little tutorial helped you in understanding, how to use the parent object, where you create a parent object and then apply it's behavior to all of the individual objects. I strongly recommend by making a chart, you can look at which one of these are going to be the same and that's what you can do for your parent, enjoy making --
Transcription by:
Scribe4you Transcription Services