效果图
请试一下下面代码,欢迎交流。html>
碰撞检测html,body{
margin:0;
padding:0;
height:100%;
}
#movele{
position: absolute;
top:0;
left:0;
height:150px;
width:150px;
background-color:#555;
border-radius: 50%;
color:#fff;
text-align: center;
}
假设这是张图片
(function(){
var elementMove=function(option){
this.container=option.container;
this.element=option.element;
this.speed = {};
if(option.speed){
if(typeof option.speed=="object"){
this.speed.x = option.speed.x;
this.speed.y = option.speed.y;
}
else{
this.speed.x = option.speed;
this