Oh darn so close…I incorporated a health system into the game so that if the targets contact ship, the ship loses life. I’ve almost gotten it to work…there’s one flaw…the coding seems right and everything, but when I play the game( I get no error msg’s) only the first target that goes by will damage me if I intersect it. All the others have no effect!..I’m pretty sure it’s related to Duplicate MC, but my knowledge of flash isn’t that great that I know how I could fix this…so here’s the fla…I bet it’s really something simple :P…the health thing works great apart from that…It even goes to a gameover frame if you lose all your health :)…well it’s a start…
That’s pretty cool. Tell ya what, when we get it working I’ll keep it hosted on my server. I’ll take a look at it tonight. I’m still house-sitting for my friends that don’t have flash so I will have to wait to get back.
Oops…here’s the attachment…
P.S. This version includes clownstaples
[AS]if(_y > Stage.height)
this.removeMovieClip();[/AS]
Thing…
(Unfortunately this version like all versions still has the bug. I don’t understand clownstaples post on how to fix it…btw…the health thing shouldn’t be hard to fix though…)
Alright, well I’ve played with it quite a bit. I used what Fargate had and what Clownstaples said about the k variable and when I increased the depth, it got worse. I named the tartgets ‘work’ because ‘target’ is part of Flash programming - I can’t seem to make it better.
When I duplicate the movieClip, I call them all by the same name, that’s why you can hit the same target ‘work’ numerous times with numerous bullets named ‘hit’. This has got to be the root of the problem, I believe.
Fargate: Love what you got going with that power bar, I don’t understand why it only works for the first one, however, it makes the game easy!!
Either way, I’ll look at it more in depth tomorrow!!
sounds good…this will be really cool when everything is fixed!!!:beam:…I might fiddle around with the file some more tonight try and add more stuff…anyways I’ll see…
bump…
hmm well i dont really feel like explaining everything right now… but i made a space ship game a while ago… maybe the FLA will help you… its kinda sloppily done because i was still learning when i made it… but here it is…
http://www.freewebs.com/scottgilmore/Galaxia.zip
some tips though…
when you duplicate your objects give them ranges when you name them…
like for instance your bullets
when you do the duplicate whatever “name”+i or however you do it… make i go from say 50-100… and then when you do your ships you do “name”+k… make k go from 101-150 when they reach their upper limit have it go back to the lower limit
ex: if(i == 100){ i = 50; }
this is good because that way you know exactly what you have to check when time comes for hit test
now when you hit test you will only need the code in either the enemy or the bullets, not both…
for this lets put it in the enter frame of the bullet
(oh yeah i also noticed you could shoot enemies more than once while they were blowing up)
onClipEvent(enterFrame)
{
for(i=101;i<=150;i++)
{
if(this, hitTest(_root[“enemy”+i]) && _root[“enemy”+i]._currentframe == 1)//only detects hit if it hasnt been hit already (meaning it is on frame 1)
{
_root[“enemy”+i].play();//plays exploding animation…
}
}
}
anyway… thats my tip… give stuff ranges so you know what the names are when you check for hit test… and i hope my FLA helps (please dont steal from it)
Thanks scott. I have questions though. I posted this earlier and no one said anything about it - I’m not using “enemy”+i, I just put “enemy” so that they are all named enemy instead of enemy43 or enemy27, etc. Could that be my bug? I’ll try it your way too.
I know that you can hit the target numerous times, wasn’t even a concern at the moment, but thanks for the code to fix it.
The hitTest code in my fla only resides in the target (instance “work”) so I’m not doubling up on the code, why do you figure the targets (at various times) will just disappear when you try to shoot them, then the problem goes away three targets later?
Not to take up too much of your time, if you don’t know, I’m sure I’ll find it eventually. Maybe you have already answered it with the range thing - but then my hitTest code would have to change as well. (???) I’ll give it a try, thank you again for helping!!
i think the naming all of them teh same may be your bug… i dont see how the hit test would be able to find teh coordinates of a mc if they are all the same name… it may work but ive never tried it… and doesnt seem likely…
so anyway look at my FLA and try what i said… hopefully it helps…
thanks…but that link doesn’t work. It just links back to kirupa.
copy and paste it in the address bar… yeah just clicking the link messes up for me too… you gotta put it in the bar
heh here it is juts for ease