plane:function(oGameBox,e){ var x=e.pageX, y=e.pageY;//鼠标到浏览器的距离 var oPlane=new Image();//获取飞机图片 oPlane.src = 'img/plane.png'; oPlane.width=60; oPlane.height=36; var lx=oGameBox.offsetLeft+parseInt(oGameBox.style.borderWidth)+oPlane.width/2; var ty=oGameBox.offsetTop+parseInt(oGameBox.style.borderWidth)+oPlane.height/2; var left=x-lx; var top=y-ty; oPlane.style.cssText="display:block;position:absolute;top:"+top+"px;left:"+left+"px;";//得到点击之后,飞机在鼠标出的位置 oGameBox.appendChild( oPlane );document.onmousemove=function(e){ e=e||window.event; var top=e.pageY-ty; var left=e.pageX-lx; oPlane.style.top=top+'px'; oPlane.style.left=left+'px'; }
添加回答
举报
0/150
提交
取消