Problem w/ sprites overlaying hitboxes
Ok, so I have a bunch of the same enemy placed, and they move around properly and everything. Their AI is coded into their hitbox, and their actual graphic is created at the start of the frame and snaps over this hitbox.
My problem is that when a sprite is destroyed, the others are destroyed as well. The hitboxes are still there though. (The problem similarly occurs when a sprite is supposed to change to a different animation; all sprites animate that way.)
The issue is that the sprite should be "connected" with its hitbox, but isn't (even though it stays snapped onto the hitbox properly). What do I do?
Re: Problem w/ sprites overlaying hitboxes
You could spread a value into an alterable variable of your objects and a similar variable in your hitboxes (Maybe call the varaible "ID". Then every frame you can attach them using:
+ID(graphic)=ID(hitbox)
-Set (graphic)position to 0,0 of (hitbox)
If you need to destroy both objects when a collision occurs, you can use:
+(hitbox) overlapping (*thing that destroys the object)
+ID(graphic)=ID(hitbox)
-Destroy(graphic)
-Destroy(hitbox)
I haven't tested it, but that should work. Of course, you may have to make it more complex or even use fastloops depending on what destroys your enemies and what happens when they die. ;)
Good Luck,
Mobichan
Re: Problem w/ sprites overlaying hitboxes
Take this
http://www.create-games.com/article.asp?id=1975
and this http://www.create-games.com/article.asp?id=1960
and this http://www.create-games.com/article.asp?id=1942
Read through those thoroughly it should help make things clearer.
Specifically the first one. "Handling Multiple Objects" You don't have to read the others but I recommend it.
Re: Problem w/ sprites overlaying hitboxes
Thanks mobichan, everything pretty much works now! The animations are still a bit off when there are several guys at once, but I'm assuming that's where fastloops will come in handy, I'll try using them later. And Mdsx, I'll make sure to keep those pages close at hand, I only read the first one so far but it was really useful. Thanks!