Page 1 of 1
Access to the Actor problem
Posted:
Tue Feb 01, 2011 6:07 am
by saikspaik
I'll be brief.
In the event MouseButtonDown (or any other), I create a new actor using the CreateActor () function, the question is how to access the created actor in the event DrawActor () or any other event?
Re: Access to the Actor problem
Posted:
Tue Feb 01, 2011 6:16 am
by schnellboot
Before you can Create Actor you have to add actor first in GE.
Then you go to actor control set No in Create at start or something and you can set the events there.
Re: Access to the Actor problem
Posted:
Tue Feb 01, 2011 7:40 am
by DST
- Code: Select all
Actor * this;
this=CreateActor("shot", "shot1", "(none)", "(none)", 0, 0, false);
ChangeAnimationDirection(this->clonename, STOPPED);
this->animpos=4;
Re: Access to the Actor problem
Posted:
Tue Feb 01, 2011 8:06 am
by saikspaik
Before you can Create Actor you have to add actor first in GE.
schnellboot You forgot to say that I need to turn on computer and run the GM.
Of course I already did that.
DSTI have tried this method, but it cumbersome. In addition, the variable "this" will only work within the current event.
Re: Access to the Actor problem
Posted:
Tue Feb 01, 2011 8:35 am
by skydereign
Well, it is easy for the created actor to access the creator actor, but to do the other way, it will be cumbersome. If you can guarantee the creator's cloneindex is the same as the created, then it is less so. What you'll need to do is use a getclone2 type function to retrieve the Actor *. Then use that in the draw. As you'll note, you need the created actor's cloneindex, so you can use a variable, or cloneindex IF that works for your situation.
Re: Access to the Actor problem
Posted:
Tue Feb 01, 2011 12:54 pm
by saikspaik
skydereign
Thanks for comprehensive answer.
I've seen on the forum method using Actor * actorVar; and getclonename (), function, but I thought that there is a simple way.
Thank you all for your answers, the question can be considered closed.