var iSpeedX=6
;
var iSpeedY=8
;
var timer=
null;
function startMove()
{
var oDiv = document.getElementById("div1"
);
timer=setInterval(
function(){
iSpeedY+=3
;
var l = oDiv.offsetLeft+
iSpeedX;
var t = oDiv.offsetTop+
iSpeedY;
if(l>document.documentElement.clientWidth-
oDiv.offsetWidth)
{
iSpeedX*=-0.8
;
l=document.documentElement.clientWidth-
oDiv.offsetWidth
}
else if(l<0
)
{
iSpeedX*=-0.8
;
l=0
;
}
if(t>document.documentElement.clientHeight-
oDiv.offsetHeight)
{
iSpeedY*=-0.8
;
iSpeedX*=0.8
;
t=document.documentElement.clientHeight-
oDiv.offsetHeight;
}
else if(t<0
)
{
iSpeedY*=-0.8
;
t=0
;
}
if(Math.abs(iSpeedX)<1
)
{
iSpeedX=0
;
}
if(Math.abs(iSpeedY)<1
)
{
iSpeedY=0
;
}
if(iSpeedX==0&&iSpeedY==0&&t==document.documentElement.clientHeight-
oDiv.offsetHeight)
{
clearInterval(timer);
alert("停止"
);
}
oDiv.style.left=l+"px"
;
oDiv.style.top=t+"px"
;
document.title=
iSpeedX;
},30
);
};
转载于:https://www.cnblogs.com/ggbd-lie/archive/2012/11/18/2776079.html
相关资源:Android小球重力感应运动有碰撞声源码的冲突文件2017-08-0410-24-13-524.rar