Skip to content Skip to sidebar Skip to footer

How To Know When Two Objects Touch Each Other

how would you know when two objects (such is divs and imgs) touch each other. I am building a mario game and I want to be able to end the level when mario 'rescues' (really just t

Solution 1:

if I understand you, you want to check when $('#mario').position() left / right / top is covering $('#peach') left / right / top.

Solution 2:

this will be perfect for you :

http://gamequeryjs.com/

anyway the thing you are looking for is called HitTest , try some google , but trust me this plugin i have attached above there will really help you alot.

and you know what , just in case you are almost done with your game and dont want to start over , use thsi directly http://plugins.jquery.com/e-smart-hittest-jquery/.

Post a Comment for "How To Know When Two Objects Touch Each Other"