Mc help

  • Jummm
  • Novice
  • Novice
  • Jummm
  • Posts: 17

Post 3+ Months Ago

Im making a defend your castle game (but in space) and i have everything worked out, but... i need it so when the bullet (called shot) hits the enemy, it plays say a movie clip called "bang" on the enemys loction?

Oh and also, on the bullet, i have this: (this isnt the full part of the script)

}
if (_root.enemy.hitTest(_x,_y,true)) {
_root.enemy.gotoAndStop(56);
}
if (_root.enemy1.hitTest(_x,_y,true)) {
_root.enemy1.gotoAndStop(56);
}
if (_root.enemy2.hitTest(_x,_y,true)) {
_root.enemy2.gotoAndStop(56);}
}

see i have to duplicate the actionscript for EACH enemy, im want to have about 3 hundred enemys in the game, or more, is the a easer way to do it?
Or should i have a

_root.shot.this.gotoandplay (56):

or something?

edit, preveiw of my game:http://img167.imageshack.us/my.php?image=castlegamegz1.swf
you can see that when they hit your base, everythings fine, but when they get shot by you, they blow up at your base....
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Jummm
  • Novice
  • Novice
  • Jummm
  • Posts: 17

Post 3+ Months Ago

Anyone?
  • Jummm
  • Novice
  • Novice
  • Jummm
  • Posts: 17

Post 3+ Months Ago

BUMP!
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

you should have a loop, of course.
Code: [ Select ]
var crtEnemy:MovieClip;
var iEnemyCount:Number = 300; // number of enemies
for (iEnemyIndex=0; iEnemyIndex<iEnemyCount; iEnemyIndex++)
{
  crtEnemy = this["enemy"+iEnemyIndex];
  if (shot.hitTest(crtEnemy))
  {
    crtEnemy.gotoAndPlay(56);
    break; // since the bullet can not shoot 2 enemies at the same time, get out of the loop
  }
}
  1. var crtEnemy:MovieClip;
  2. var iEnemyCount:Number = 300; // number of enemies
  3. for (iEnemyIndex=0; iEnemyIndex<iEnemyCount; iEnemyIndex++)
  4. {
  5.   crtEnemy = this["enemy"+iEnemyIndex];
  6.   if (shot.hitTest(crtEnemy))
  7.   {
  8.     crtEnemy.gotoAndPlay(56);
  9.     break; // since the bullet can not shoot 2 enemies at the same time, get out of the loop
  10.   }
  11. }

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.