MoveCollideX on [multiple] types? (SOLVED)


(christopf) #1

Hi i’ve searched for an explanation of the moveCollide method but only find a few topics scratching on it since their authors seem to know howto. i “switched” my hero movement to moveTo and now i want to check collision for single enemy types but the movecollide seems to work only with specific entities. is there a way around like creating a entity representing an array of types?


(Bora Kasap) #2
collidelist:Array = new Array(new String("archertype"), new String("swordsmantype"));

moveTo(x, y, collidelist);

(christopf) #3

miauz sorry. i didnt ask clearly enough. i want different events happen when colliding with different types. to now i thought the collision option in the moveTo tag is only for stopping? or can i define the general collision reaction of moveto and moveby with the movecollide method?


(Jacob Albano) #4

Override moveCollideX(e) and moveCollideY(e). You can check the type of each entity you collide with and return true if it should result in a collision.


(Jacob Albano) #5

Or:

collidelist:Array = ["archertype", "swordsmantype"];

Just to cut out some redundancy. :wink:


(christopf) #6

thank you both! it works now!