Page 1 of 1

In need of aid

PostPosted: Sun Sep 27, 2009 10:14 am
by luckydog
Sorry if this is in the wrong section. I wasn't sure it was serious enough to go into the game development section, but feel free to move it if it's in the wrong forum.

Now, I wanted to make my enemies spawn at a random y position but I can't seem to find any documentation on using such a thing. I'll keep searching, but if you could help me it'd be much appreciated.

Re: In need of aid

PostPosted: Sun Sep 27, 2009 12:38 pm
by makslane
You can use the 'Create Actor' event with the script:

Code: Select all
y = rand(view.height);

Re: In need of aid

PostPosted: Sun Sep 27, 2009 5:43 pm
by DST
For a little extra spawning control, i set my actors to do this on startup:

y=starty;

where starty is a global variable. Then, in the script that spawns the actors,

starty=rand(400)+40;
CreateActor(blah blah, blahx, starty, true);

(int a 640 x480 game, this will spawn between 40 and 440, so enemies won't be partially offscreen).

Now if you need to make arrays of enemies, you can always just set starty before spawning them. You can do the same thing with their health, speed, type, whatever.

for (i=0; i<10; i++){
starty=(i*40);
CreateActor(...
}

now you can spawn them in neat patterns.