Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-18-2009, 08:44 AM   #1
Registered User
Join Date: Mar 2009
Posts: 1
Question [AS2] shooting, problem with enemies

hi all,
i have been making a game where you shoot enemies, to keep it breef.
getting straight to the point, every bullet works fine, moves with other code and has the instance name of bullet2. that all works fine. the enemies are doing what i want them to do but when it comes to shooting the enemies i am stuck.
each enemy has the instance name of enemyi, i being a number added on each time an enemy is created. once this reaches 50 it goes back to 1. there can not be more that 50 enemies at once(no matter what :P). in the bullet i have this code:

for (i = 1;i < 51; i++){
if (this.hitTest(_root["enemy"+i])){

the problem is when i test the movie the bullet senses that it has hit the first enemy, only the first enemy, but no others. also the first enemy does not delete.
thanks very much

any help is greatly appreciated.
HarryVince is offline   Reply With Quote
Old 03-18-2009, 05:12 PM   #2
Senior Member
Join Date: Sep 2005
Location: NYC
Posts: 250

ActionScript Code:
for (i=1; i<51; i++) {     var tempEnemy = eval("_root.enemy"+i);     if (this.hitTest(tempEnemy)) {         removeMovieClip(this);         removeMovieClip(tempEnemy);     } }

keep in mind that removeMovieClip works only with movieclips attached at runtime or duplicated at runtime
FreeActionScript.com- AS2 & AS3 Game Tutorials, Samples, Source Files & Downloads
pradvan is offline   Reply With Quote

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS2] I have an AI problem ibrabdo Gaming and Game Development 0 03-01-2009 11:28 AM
[AS2] A lengthy problem - game design Vagabond Gaming and Game Development 7 02-19-2009 12:46 AM
[AS2] Rotating line Problem Scorpio1243 Gaming and Game Development 8 02-11-2009 03:11 PM
[AS2] basic game__array problem menocchio Gaming and Game Development 3 11-26-2008 05:25 AM
Shooting game problem Morret Gaming and Game Development 1 06-16-2005 04:11 AM

All times are GMT. The time now is 09:29 AM.

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.