How do I declare a pointer of type Actor locally?

Game Editor comments and discussion.

How do I declare a pointer of type Actor locally?

Postby yttermayn » Mon Jan 21, 2008 11:29 pm

How do I declare a pointer of type Actor locally? I want an actor to be able to store a pointer to another actor it created, locally.

Thanks!
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score

Re: How do I declare a pointer of type Actor locally?

Postby makslane » Tue Jan 22, 2008 1:09 am

Use the return value of the CreateActor action:

Code: Select all
Actor *myactor = CreateActor(...);
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: How do I declare a pointer of type Actor locally?

Postby DilloDude » Tue Jan 22, 2008 1:22 am

If you want to store an actor as an actor variable, you have to use some other kind of variable. Strings work well. Just store the actor's clonename:
Code: Select all
Actor *actor = CreateActor(...
//stuff with actor
strcpy(string, actor->clonename);

Then use getclone to turn it back into an actor:
Code: Select all
Actor *actor = getclone(string);
//stuff with actor
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: How do I declare a pointer of type Actor locally?

Postby yttermayn » Tue Jan 22, 2008 4:44 am

Actor *actor = CreateActor(...

Dosn't the above have to go into a global code area? That's the only place I've been able to get a string declaration to work. If that's the case, it's no good - the createactor() is executed by another created actor's "create actor" event script, which won't let me use the line as shown above. Maybe I should just say what I'm doing and ask how you would do it:

My view -> draw actor script at some point creates a zombie actor. The new zombie actor creates a text actor to display hit points above its head in the zombie -> create actor script.

What is the easiest way to do this? Maybe I've just been looking at it all wrong...
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score

Re: How do I declare a pointer of type Actor locally?

Postby yttermayn » Fri Jan 25, 2008 3:42 pm

Allright! Thanks, Dillodude. Once I figured out another problem, your method worked out nicely. Points for you!
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron