演示地址
調用示例
var GCDM = gcdMove(oDiv
GCDM
GCDM
該段JS代碼已經封裝好了
簡要說明
/**
* @Desc 重力碰撞拖拽運動
* @Author GenialX
* @URL www
* @QQ
* @Date
*/
function gcdMove(obj
_this = this;//public identifier
//construct fun
var gcdMove;
//self defined fun
var start;
_this
//other var
var iTimer;
var iLastX =
var iLastY =
//construct fun
start = function() {
clearInterval(iTimer);
iTimer = setInterval(function() {
iSpeedY +=
var l = obj
var t = obj
if (t >= document
iSpeedY *=
iSpeedX *=
t = document
} else if (t <=
iSpeedY *=
iSpeedX *=
t =
}
if (l >= document
iSpeedX *=
l = document
} else if (l <=
iSpeedX *=
l =
}
if (Math
iSpeedX =
}
if (iSpeedX ==
clearInterval(iTimer);
}
obj
obj
}
}
_this
obj
clearInterval(iTimer);
var oEvent = ev || event;
var disX = oEvent
var disY = oEvent
document
var oEvent = ev || event;
var l = oEvent
var t = oEvent
obj
obj
if(iLastX ==
iLastX = l;
}
if(iLastY ==
iLastY = t;
}
iSpeedX = l
iSpeedY = t
iLastX = l;
iLastY = t;
}
}
obj
document
document
document
start();
}
start();
}
_this
clearInterval(iTimer);
obj
document
obj
iLastX =
iLastY =
iSpeedX =
iSpeedY =
disX =
disY =
}
//CONSTRUCT AREA
var gcdMove = function() {
if (!iSpeedX) {
iSpeedX =
}
if (!iSpeedY) {
iSpeedY =
}
}
gcdMove();
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20564.html