我想移动到一个矩形。当它到达行尾时,换行并将其放在下一行的开头。矩形没有很好的坐标来换行。有任何想法吗?这是我的功能:
<script type="text/javascript"><![CDATA[
var rect = document.getElementById('player');
var x = rect.getAttribute('x')*1,
y = rect.getAttribute('y')*1;
setInterval(move, 30);
function move()
{
if (rect.getAttribute('x') < 500){
rect.x.baseVal.value = ++x;
}
else if (rect.getAttribute('x') >= 500){
rect.x.baseVal.value = x-250;
rect.y.baseVal.value = y+250;
}
}
]]></script>
谢谢!