Page 1 of 1

Need help with this...

PostPosted: Sat Mar 06, 2010 4:30 pm
by MrJolteon
How can I create an actor ingame with a random animation through Create Actor event?
I'm making a breakout game(Super Mario Breakout), and the block have different animations(question block, red koopa, green koopa, blue koopa, shyguy, green mushroom. All from the Super Mario games). So, plz help me(oh, yea and they're generated with script, not clones)

Re: Need help with this...

PostPosted: Sat Mar 06, 2010 6:48 pm
by skydereign
This creates actorName with a randomly selected animation, replace the 5 with however many animations the actor has.
Code: Select all
CreateActor("actorName", getAnimName(rand(5)), "(none)", "(none)", 0, 0, false);

Re: Need help with this...

PostPosted: Mon Mar 08, 2010 8:56 am
by MrJolteon
ok, thanks
Edit:
Do the first animation count as 0 or 1 in that script?
Edit2:
It didn't work... in the code I have this:
actor: racket>Create Actor>Script Editor
Code: Select all
int i, j;
char brick[5][10] =
{
{1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
{0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
{0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 0, 1, 0, 1, 0, 1, 0, 1, 0}
};count = 0;
for(j = 0; j < 5; j++)
{
    for(i=0; i < 10; i++)
    {
      if(brick[j][i]) CreateActor("metalBlock1", getAnimName(rand(6)), "(none)", "(none)", 0, 0, false);
    }
}



What's wrong?

Re: Need help with this...

PostPosted: Mon Mar 08, 2010 11:21 pm
by skydereign
Well, it probably is due to you not changing the xy position in the create actor script. The first animation is 0.