| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jul 2001
Posts: 2
|
I am trying to write a small game based on the Laser Game tutorial and using hitTest().
There can be any number of instances existing for the 'bullet' and also for the 'target'. Therefore, hard coding the testing by bullet1, bullet2 .... bulletn would be impossible. So, I need to detect a hit from any instance of a MovieClip... is this possible? My alternative is to keep track of names of all existing instances of each and write a function that constantly loops through each target and hitTests on each exisitng bullet... this would be damned slow ![]() Thanks in advance Toad |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Jul 2001
Posts: 2
|
I've sorted that problem out by keeping an array of the _names ...
New Problem: I make my target appear (duplicatemovie) in the first(and only) frame of the movie... but when I fire my target disappears, what could I have done wrong? Toad |
|
|
|
|
|
|
|
|
#3 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
Make certain you aren't duping a movie into the layer that your target exists on. What a lot of people do is reserve ranges of levels for their objects. Think about how many laser beam thingies can be on screen at once. I doubt it'd be more than like 500, so reserve levels 500 to 1000 for your laser beams. Have some kind of check coded to reuse the levels based on the dupe's position on the stage. If the MC is off-stage, re-use it's level because it's no longer visible.
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Note you could also use a for..in loop instead of a name array.
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2 events with small button above a large button | blob | ActionScript 2.0 | 8 | 01-05-2005 06:26 AM |
| [AS2] Tile game or not tile game? | krolben | Gaming and Game Development | 4 | 07-28-2004 01:41 PM |
| small game partnership | speedlemon | Projects and Positions | 2 | 07-06-2004 08:47 PM |
| Small online game company needed. | zekebru | Projects and Positions | 0 | 08-23-2001 07:38 PM |