Need help with this...

Non-platform specific questions.

Need help with this...

Postby MrJolteon » Sat Mar 06, 2010 4:30 pm

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)
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Need help with this...

Postby skydereign » Sat Mar 06, 2010 6:48 pm

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

Re: Need help with this...

Postby MrJolteon » Mon Mar 08, 2010 8:56 am

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?
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Need help with this...

Postby skydereign » Mon Mar 08, 2010 11:21 pm

Well, it probably is due to you not changing the xy position in the create actor script. The first animation is 0.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest