Access to the Actor problem

Game Editor comments and discussion.

Access to the Actor problem

Postby saikspaik » Tue Feb 01, 2011 6:07 am

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?
saikspaik
 
Posts: 14
Joined: Wed Jan 05, 2011 8:17 am
Score: 1 Give a positive score

Re: Access to the Actor problem

Postby schnellboot » Tue Feb 01, 2011 6:16 am

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.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Access to the Actor problem

Postby DST » Tue Feb 01, 2011 7:40 am

Code: Select all
Actor * this;

this=CreateActor("shot", "shot1", "(none)", "(none)", 0, 0, false);
ChangeAnimationDirection(this->clonename, STOPPED);
this->animpos=4;
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Access to the Actor problem

Postby saikspaik » Tue Feb 01, 2011 8:06 am

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.

DST
I have tried this method, but it cumbersome. In addition, the variable "this" will only work within the current event.
saikspaik
 
Posts: 14
Joined: Wed Jan 05, 2011 8:17 am
Score: 1 Give a positive score

Re: Access to the Actor problem

Postby skydereign » Tue Feb 01, 2011 8:35 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Access to the Actor problem

Postby saikspaik » Tue Feb 01, 2011 12:54 pm

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.
saikspaik
 
Posts: 14
Joined: Wed Jan 05, 2011 8:17 am
Score: 1 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron