PDA

View Full Version : small game - instanceOf ?


Toad
07-15-2001, 09:09 AM
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

Toad
07-15-2001, 12:53 PM
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

20 Ton Squirrel
07-16-2001, 02:18 PM
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.

Jesse
07-17-2001, 06:25 AM
Note you could also use a for..in loop instead of a name array.