At 11/13/13 07:50 PM, bambuy wrote:
But for some reason when i place the next zombies on, at the tween etc...
Tweens only work on 1 symbol per layer.
they dont enter the stage when i preview the game.
If you were using a tween, they would not enter even in the Flash IDE, let alone SWF.
Everything else works fine, the background continues to play etc but the next set of zombies wont show up!!!
So the first set of zombies shows up properly, only the next sets are not appearing?
*all caps panicking*
First of all, using a tween to make a game is a horrible idea, but it is possible. So we're going to continue using tweens, so that you do not advance in knowledge/experience faster than your intellect allows.
After you spawn zombies, you must wait until the player kills them, so you must put a stop() command on the main timeline. Not just a stop command, you must also check how many zombies you have, and if 0, then you advance further.
//if zombie_count does not equal 0 then do this
The problem right now is that zombie_count is not defined anywhere in the game. So you must define zombie_count on the first frame of the main timeline by using code:
Then, inside the zombie, when you remove it, you must ADD this code to the last frame (where you remove the zombie) of the zombie's timeline:
//one zombie died, so we decrease the zombie_count by 1
//if zombie_count is 0, then resume the game onto the next wave of zombies
Now the final problem is that zombie count is never increased. Very simple: increase the zombie count on the first frame of the zombie, where you have a stop command (you need to ADD this code to the first frame of the zombie):
//this line of code adds 1 to the zombie_count
Why am I writing _root all the time? Because the code is in the zombie, and the variable zombie_count is in the _root, so in order to refer to the zombie_count variable, which I cannot do directly from zombie, I must type _root everywhere. Same with play command. If I just typed play(); inside the zombie, then I would play the zombie, not _root, and by writing _root.play(); I explicitly specify that I intend to play the _root, not the zombie.
Now, the final (again, for programmers all problems are always final lol, cause they forget what they had to do and they write code faster than they think) problem is making the next wave. To do this, you can either manually tween zombies again, or you can replay the entire game from a certain frame.
So let's say after the last wave you make a frame with code:
And the game will rewind from that frame, repeating endlessly.
I was thinking very hard, but it is not possible to make a solution for this which does not involve code, or involves very little (and simple) code, at least simpler than this, so sorry if I've just squeezed your brain too tight and you got a headache.