samedi 25 mars 2017

.hitTestPoint hitting multiple test points (AS3)

I can write a hitTestPoint trigger as such

if (mc1.hitTestPoint(mc2.x, mc2.y, true)) 

and if I want to have multiple test points I can write something like

if (mc1.hitTestPoint(mc2.x, mc2.y, true) || mc1.hitTestPoint(mc2.x-5, mc2.y, true) || mc1.hitTestPoint(mc2.x+5, mc2.y, true))

I am wondering though if there is anyway to define multiple hitpoints in the same statement. I've tried something like this with no luck...

if (mc1.hitTestPoint((mc2.x, mc2.y, true) || (mc2.x, mc2.y, true))) 

or

if (mc1.hitTestPoint((mc2.x+5 || mc2.x-5), mc2.y, true)) 

...and many others but nothing seems to work. It is a pain to write the new points out for the same object over and over especially when you have 20+ hitpoint that you need to check for. Is there any way to add multiple points in one statement?

Aucun commentaire:

Enregistrer un commentaire