how to set a limit on the number of spawn actor
rino
Member Posts: 17
Hello everyone,
I"m not sure if this is the right section to post this. But I am having trouble finding out how to set a limit to the number of 'enemies' that spawns automatically.
as well, how do i prevent a character from walking off the screen? Do I just put solid platforms or wall on the side or is there another way?
Thank you!
I"m not sure if this is the right section to post this. But I am having trouble finding out how to set a limit to the number of 'enemies' that spawns automatically.
as well, how do i prevent a character from walking off the screen? Do I just put solid platforms or wall on the side or is there another way?
Thank you!
Comments
Rule: when (game.attribute integer) game.NumEnemies (less than or equal to) 5 (or however many you want)
game.NumEnemies = game.NumEnemies +1
For the boundaries, yes you can make an actor bounce off unmoveable walls that you have the alpha (visibility) set to 0 or you can even constrain the actor with a rule that says if their X or Y position is a certain number, change it to that number again, so it never goes past that value (or off the screen).
*edit* The value would be the screen size you want to constrain it to. for instance if it's iphone portrait mode, and you're constraining up and down, Y would be if self.position Y (greater than or equal to) 470 (because the total height is 480), change self.position Y to 470. Do the same for all directions.
One last question.. Is there an easier way to do animations. For example, I have a cartoon image of a boy, If I want to amine him to run, I would have to cut the legs and arms separately to rotate them for each image? And if this was the only option, which program for MacBook pro can do this? There is not event a paint program on Mac? Sorry I'm new to Mac ...
Thanks in advance again!
As for forklifts reply earlier, I am still stuck. Let me clarify the question again.
I am trying to make level one of my game to spawn only 5 enemies and no more. Whether I collide anything with the enemy to destroy it or not doesn't matter. So for example, one enemy is worth 50 points, so the maximum number of points I get for this level is 50 points. I followed your instructions and here is what I did:
I went into the inspector and added an 'interger' and named the actor NumEnemies and the value was set at 5.
Then I went to the enemies actor and edited it. I currently have a rule that says when I collides with a certain object it will be destroyed.
So I tried press the (+) button and add 2 more lines of:
(Attribute)(game.Numenemies)(<)(5)
(Attribute)(game.Numenemies)(=)(game.Numenemies)+1
I also tried putting this as a separate rule and changing the (game.numenemies+1) to 6 (cause I didn't know if you actually wanted me to plus 1)
I also tried to change the spawner actor that i have for randomly spawning the enemies but didn't work either.
Thank you for your time once again.
Rino
thanks for your quick reply.
I am sorry, I must be doing something wrong cause I can't get it to work.
So ... First I in the 'inspector' I need to add the "integer" and call it NumEnemy
Second I go into my 'spawner' actor and put the RULE out and choose (attribute)(game.numenemy)<5
Third ... in the next line I add another attribute (game.numenemy) = (game.numenmy)+1
Forth I drag in my timer which I set to random
Then under the timer I set my spawn actor
I am not sure what I'm doing wrong but if I set the attribute to <5, a lot of enemies keep spawning non stop
But if I set the 2nd line to game.numenemy to numenemy+1, won't that mean nothing will spawn if there are not 6 enemies on the field?
P.S. (How does this integer attribute work? Does the value of the integer automatically go up by 1 every second and this is how gamesaland is able to tell when the 'integer' has reached 5)?
Sorry I probably make no sense...
Thank you once again!
Set the attribute to (attribute)(Numenemy)(<)(5)
then spawn actor (the enemy)
and then I put a
Change attribute bar (game.numenemy) to (game.numenemy)+1.
Thanks forklift and Tshirtbooth!