如何知道两个物体何时相互接触 [英] How to know when two objects touch each other
问题描述
您如何知道两个对象(例如div和imgs)何时相互接触.我正在开发一款马里奥游戏,我希望能够在马里奥救援"(真的碰到)公主桃子时结束游戏.
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 touches) princess peach.
推荐答案
这对您来说是完美的:
无论如何,您正在寻找的东西叫做HitTest,尝试一些google,但是请相信我,我在上面附加的这个插件确实可以为您提供很多帮助.
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/.
这篇关于如何知道两个物体何时相互接触的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!