Page 1 of 1
Create Actor Question
Posted:
Sun Oct 02, 2005 8:28 pm
by MiG3
I have an actor that creates another actor, with this code:
CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);
How can I give this new instance certain values? What I want to do, like I do in Game Maker, is this:
aa=CreateActor(...);
aa.variable=value;
I just want to affect this instance of the actor, not all of them, so I can't use Scroll's CreateActor event.
Thanks,
MiG3
Posted:
Mon Oct 03, 2005 1:30 am
by makslane
Try this:
Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);
newactor->yourvariable = value;
Posted:
Mon Oct 03, 2005 2:21 pm
by MiG3
As soon as I put the actor declaration thing down, I got an error
Scroll_Effects[0]=0;
Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);
Error: Unexpected declaration Scroll_Effects.
I got another error for
newactor.name = Scroll_Names[0];
Error: Illegal structure operation
Why is it saying that?
MiG3
Posted:
Tue Oct 04, 2005 2:18 am
by makslane
Error: Unexpected declaration Scroll_Effects.
What is "Scroll_Effects"? is a string array?
newactor.name
newactor is a pointer, so, you must refer the mebers with '->' not '.'
newactor->name
And...
To copy a string you need use the strcpy function:
strcpy(string, "hello!");
Other problem, the actor's name is a read only variable, so, you can't change.
Posted:
Tue Oct 04, 2005 8:59 pm
by MiG3
What is "Scroll_Effects"? is a string array?
Yes, it is. Don't see how it affects anything but yes. It worked fine before I had that declaration that came after it.
strcpy(string, "hello!");
That doesn't help very much. K. Look. He said
Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);
Now, how do I use that whilst using strcpy? I need an example, because it doesn't make sense without one.
Thirdly, I tried this:
newactor->fire=1;
But alas, it decreed an
Error: Illegal Structure Operation.
This might have to do with the fact that the Actor *newactor command isn't working, and newactor isn't pointing yet, but just to make sure it's right, I'm posting it here.
MiG3
Posted:
Tue Oct 04, 2005 10:16 pm
by makslane
Is the fire variable an actor or global variable?
To works must be a actor variable.
Posted:
Tue Oct 04, 2005 11:31 pm
by MiG3
It's an actor, and that line works now. I still don't know how to do the create actor thing though.
Could you post an example of the create actor thing?
Posted:
Wed Oct 05, 2005 1:49 pm
by makslane
Can you send me your game?
Posted:
Wed Oct 05, 2005 9:49 pm
by MiG3
For some reason the computer I have the game on won't connect to this website at all. It keeps sending me to
http://www.game-editor.com:19638/webhost/rollout/site.
Could you just type an example on how to create an actor, and change one of those actor's variables?
MiG3
Posted:
Wed Oct 05, 2005 10:40 pm
by makslane
I'm making some changes in the server, I think will be stable tomorrow.
I don't know what you need. The codes in this post must works:
Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);
newactor->fire = 10; //If fire is an integer or real actor variable
Posted:
Wed Oct 05, 2005 10:42 pm
by Joshua Worth
MiG3 wrote:For some reason the computer I have the game on won't connect to this website at all. It keeps sending me to
http://www.game-editor.com:19638/webhost/rollout/site.
Could you just type an example on how to create an actor, and change one of those actor's variables?
MiG3
It happened EVERYWHERE!