Collision function (with any type?)


(billy2000) #1

Well I use alot the collision function and I use it for each type of entity i have . My question is: Is there a collide function that can include every entity that has a hitbox,insted of doing a collision for each type of entity(collide(“entity”,x,y))?


(Brad Davies) #2

I know you can do a test against multiple types using;

var e:Entity = WHATEVER YOUR ENTITY IS
if(e.collideTypes(["enemy","bomb","spikes"],e.x,e.y))
{
    doWhatever
}

(billy2000) #3

can i do something for DIFFERENT ENTITYES with different type too?


(Ultima2876) #4

Put the entities you want to collide into a Vector or array and then iterate over them with a for loop.


(billy2000) #5

well i allready made something almost like that …just whanted to know if there is a efficient way of doing that . Thx guys :slight_smile: