Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-18-2011, 02:42 AM   #1
Bic
Fellow RPG Maker!
 
Join Date: Dec 2010
Location: Canada
Posts: 36
Send a message via AIM to Bic Send a message via MSN to Bic
Default [AS2] How To Detect # of Movie Clips

Lets say I want to duplicate the movie clip "enemy". I only want 3, and if an enemy gets killed, it will start a timer (like a spawn time) and then duplicate a new enemy movie clip, but only when there is less than 3 on the screen.

So, how do I make an if statement like...

if(#ofenemy < 3){
duplicateMovieClip();
}

Any help?
Bic is offline   Reply With Quote
Old 05-18-2011, 04:08 AM   #2
Bic
Fellow RPG Maker!
 
Join Date: Dec 2010
Location: Canada
Posts: 36
Send a message via AIM to Bic Send a message via MSN to Bic
Default

Or if I...

Just duplicated the movie clip x times and just made spawn timer and duplicate movie clip... That could work.
Bic is offline   Reply With Quote
Old 05-18-2011, 02:33 PM   #3
Sandile
Registered User
 
Join Date: May 2011
Location: Sweden
Posts: 22
Default

I dont really understand the last post you made. But to answer your first post, this is my suggestion:
You make a variable that you call like enemies. When a new enemy spawn you add 1 to the enemies variable and when a enemy dies you remove 1 from the variable
so like:
Code:
var enemies = 0;

this.onEnterFrame = function(){
  if(enemies < 3){
    starttimerfunction /* you'll have to make one yourself, if you need help I 
    can tell you how */
    if(timer == 0){
      duplicateMovieClip();
      enemies ++;
    }
  }
}
and you use this when you spawn a new enemy
Code:
enemies ++;
and
Code:
enemies--;
when a enemy dies.
Sandile is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:24 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.