• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved] Parent/Child Objects

curato

Member
I am having an odd issue with the latest version of Game Studio 1. I have a parent object with all the functions in it and then several child objects. when I left click on a child object all the child objects fire off there left released even. I know I could work around it but I fell like I am missing something simple.
 

spe

Member
I think we're going to need a little more information to figure out what's going on here. Here is what I'm assuming from your post, correct me where I'm wrong:
You have one parent object with a left mouse released function.
None of the children objects have a left mouse released function of their own.
You click and release on a child object and all the different child objects fire, OR all the different instances of that particular child object fire?
It sounds to me like your code is only looking for a click, not a click on a particular instance. You do need to check to make sure that only the instance being clicked will fire. Something like this:
Code:
if point_in_rectangle(mouse_x, mouse_y, /*put the coordinates for the object you want to click in here, using 'x' and 'y' */) {
        if mouse_check_button_released(mb_left) {
           //Run your code
        }
}
Note that this may not work so well if you have objects overlapping at any point. I'm not sure what your project requires, as I have no idea what it is.
 

curato

Member
Never mind. I just came here to say I figured it out. Not sure why but I just deleted all the objects in question and made them again and it worked just like I thought.
 
Top