PDA

View Full Version : Constant Duplicate MovieClip


piratefish
03-03-2006, 04:14 AM
I'm trying to have a constant flow of duplicated movieclips to be created while a variable is beneath a certain fixed amount.

while (_root.monCount<13) {
trace("Monster Count is="+monCount)
//Duplicates the monster movieclip
duplicateMovieClip("monster_mc", "monster"+monCount, monDepth);


There's more various positioning code for each new clip, but that's not important. It does increase the monCount and the monDepth when the end of the cycle is reached.

My only problem is when I remove a movieclip (via a hitTest) and subtract from the monCount. It doesn't work at all.

if (this.hitTest(_root.warrior_mc.sword)) {
// Drop loot here with a duplicated movieclip
removeMovieClip(this);
_root.monCount-=1
}


The monDepth keeps being added to so nothings on the same depth. But anyways if ten of the movieClips are removed I'm lucky to get about three of them to reappear. Does anyone have some advice to offer in this? Thanks for any help.

Ricod
03-05-2006, 05:49 PM
It's hard to tell what exactly happens. Did you try tracing the monCount in the last piece of code? Theoretically it ought to subtract 1 from the count and then the first piece ought to spawn a new monster then.

Maybe if you subtract 1 from the monCount first and THEN remove the clip ?

Also:
_root.monCount-=1;

can also be written as

_root.monCount--;

Saves you 1 character. ;)