Page 1 of 1

get the parent (location) of clone

PostPosted: Sun May 28, 2006 8:44 am
by geuser7
I need to be able to find the parant x y postion of a clone so I can draw a line from the clone to the parent.
I see reference to the getclone function but the docs are not clear to me of how to use it for various purposes.
I thought it might be used something like this:
lineto(getclone(myclonename)->Parent->xscreen, getclone(myclonename)->Parent->yscreen);

Anyway the above code does NOT work for drawing to parent but
moveto(getclone(myclonename)->xscreen, getclone(myclonename)->yscreen);
will move to my clone..

How can I get the position of a clones parent??

PostPosted: Sun May 28, 2006 1:30 pm
by DilloDude
The only way I can think of at the moment is to create a variable (such as a string) and assign it to an actor's parent. Make a string variable called 'ParentActor', and make it an Actor variable. Add a drawactor, with
Code: Select all
strcpy(Parentactor, parent.clonename);

If you want to access it, use
Code: Select all
getclone(getclone(clone)->ParentActor)->x = 5;

You could possibly create an Actor struct, so reference could be
Code: Select all
ParentActor->x = 5;
but I don't know how you could make ona an Actor variable.

access to parent

PostPosted: Sun May 28, 2006 5:09 pm
by geuser7
strcpy(Parentactor, parent.clonename);
I understand that Parentactor is the variable I should create... and that clonename I should replace with my actual clone name... but the "parent." I am not sure of... am I to supply the name of the parent or but placing "parent." in front of my clone name will it supply the actual clone name to me inside my Parentactor variable?

If I have to provide the name of the parent before hand I will not be able to do that... my parents are changing with colisions and I need to figure out which has become a parent...

Also:
getclone(getclone(clone)->ParentActor)->x = 5;
= 5 seems to be assigning a location? ... When I want to retreive the parents location? ... Am I misunderstanding?

... Not sure how to get your samples to work yet... I did try:
strcpy(ParentActor, parent.myclonename);
lineto(getclone(getclone(myclonename)->ParentActor)->xscreen,getclone(getclone(myclonename)->ParentActor)->yscreen);

But ... not working...

Can you advise me more how to come up with the clones parents location?

PostPosted: Sun May 28, 2006 11:42 pm
by DilloDude
If you just use parent.clonename, it will return the clonename of the actor's parent. So if your parent is actor.3, then it will set the string Parentactor to "actor.3". When you change the parent, you can say it again, or, in a collision, use collide.clonename instead. Then if you want to access the parent of actor.5, you can use
Code: Select all
getclone(getclone("actor.5")->Parentactor)->variable
and do what you like with it.