2011-03-25 93 views
0

我剛開發了一個帶有兩個div的baloon遊戲。一個是水平移動,另一個是垂直移動。基於HTML的遊戲:使用jQuery檢測碰撞

問題是,當兩個div彼此接觸時,我無法觸發函數。

+2

你可以添加你的「移動」的代碼某些部分? – neebz 2011-03-25 07:50:49

回答

0

創建每一部電影的部分作爲單獨的對象

找到每個所創建的對象的座標的每個第二或使用一些milisecond settimeinterval

如果對象座標是相同或在邊界;破壞對象。

0
function detectCollision(){ 

    //detect the top and let of balloon 1 
    //detect the top and left of balloon 2 
    //check if the top and left are same or in a required range 
} 

調用此函數以取決於您的移動速度的時間間隔,這將碰撞檢測