News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

SpriteHit Versus SpritesOverlap

Started by Rembrandt Q Einstein, August 05, 2007, 11:38:00 AM

Previous topic - Next topic

Rembrandt Q Einstein

Hey, I was wondering why I keep hearing that it is preferable to use SpriteHit over SpritesOverlap for sprite collision detection.

Say I'm going through my bullets and I want to see if one hit an enemy.  I can go through my active enemies and use SpritesOverlap for each enemy, or I can do pretty much the same thing, only use collision classes and SpriteHit.  But with SpritesOverlap, I get to know the array index of the enemy I hit, instead of its sprite index.  I know i can use SpriteLocalVariables to communicate the hit to my enemy, but this is less convenient than just having the array index.

So is there a performance advantage to using SpriteHit that makes up for this convenience disadvantage?

kevin


QuoteSay I'm going through my bullets and I want to see if one hit an enemy.  I can go through my active enemies and use SpritesOverlap for each enemy, or I can do pretty much the same thing, only use collision classes and SpriteHit.  But with SpritesOverlap, I get to know the array index of the enemy I hit, instead of its sprite index.  I know i can use SpriteLocalVariables to communicate the hit to my enemy, but this is less convenient than just having the array index.

    That's rather subjective.



QuoteSo is there a performance advantage to using SpriteHit that makes up for this convenience disadvantage?
Quote

    SpriteHit supports caching...  SpriteOverlap doesn't.

Rembrandt Q Einstein

Caching, ok.  Also, i like being able to check against 2 different classes at once, (bossclass + enemyclass for example).  Also, it better allows you to seperate your code, because you deal with the hit in the enemy.pbb instead of where you're checking.

So just asking this question gave me an opportunity to think about each one's pros and cons.