赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2008-10-10 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 35
- 在线时间
- 0 小时
- 注册时间
- 2008-10-3
- 帖子
- 3
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
function Map(_basesrc, _rows, _cols, _clientWidth, _clientHeight, _width, _height)
{
this.map = window.document.createElement("div");
this.mapcontainer = window.document.createElement("div");
this.mapTable = window.document.createElement("table");
this.mapcontainer.style.position = "absolute";
this.mapcontainer.appendChild(this.mapTable);
this.mapcontainer.style.pixelLeft = 0;
this.mapcontainer.style.pixelTop = 0;
this.mapTable.cellSpacing = 0;
this.mapTable.cellPadding = 0;
for(var i=0;i<_rows;i++)
{
var tr = this.mapTable.insertRow();
for(var j=0;j<_cols;j++)
{
var td = tr.insertCell();
var img = window.document.createElement("img");
//_basesrc = _basesrc.replace(/\$x/, i);
//_basesrc = _basesrc.replace(/\$y/, j);
img.src = _basesrc;
//img.width = 186;
//img.height = 100;
//td.appendChild(map);
td.appendChild(img);
}
}
//this.mapcontainer.innerHTML=this.mapcontainer.innerHTML+'<div id="moveland"></div><img id="clickimg" src="images/click.gif">';
this.mapcontainer.innerHTML=this.mapcontainer.innerHTML+'<div id="moveland"></div>';
this.minimap = null;
this.clientWidth = _clientWidth;
this.clientHeight = _clientHeight;
this.width = _width;
this.height = _height;
this.rows = _rows;
this.cols = _cols;
this.mapmovetimer = null;
this.movespeed = 20;
this.ScrollLock = false;
this.owner ="ID" + this.map.uniqueID; //保存对象本身
eval(this.owner + "=this"); //通过this.owner
this.map.appendChild(this.mapcontainer);
this.map.style.clip="rect(0 "+this.clientWidth+" "+this.clientHeight+" 0)";
this.map.style.position = "absolute";
this.map.style.width = this.clientWidth;
this.map.style.height = this.clientHeight;
this.map.style.pixelLeft = 0;
this.map.style.pixelTop = 0;
this.map.style.zIndex = 1; //地图永远在最底层
this.resize = function(_clientWidth,_clientHeight)
{
this.clientWidth = _clientWidth;
this.clientHeight = _clientHeight;
this.map.style.clip="rect(0 "+_clientWidth+" "+_clientHeight+" 0)";
this.map.style.width = _clientWidth;
this.map.style.height = _clientHeight;
}
this.getX = function()
{
return this.mapcontainer.style.pixelLeft;
}
this.getY = function()
{
return this.mapcontainer.style.pixelTop;
}
this.setX = function(x)
{
this.mapcontainer.style.pixelLeft = x;
}
this.setY = function(y)
{
this.mapcontainer.style.pixelTop = y;
}
this.setPos = function(x,y)
{
this.setX(x);
this.setY(y);
}
this.scrollTo = function(_x, _y)
{
this.MoveStop();
if(_x>this.width-this.clientWidth/2) _x = this.width - this.clientWidth/2;
if(_y>this.height-this.clientHeight/2) _y = this.height - this.clientHeight/2;
var x = _x - this.clientWidth/2;
x = x>0 ? -x : 0;
var y = _y - this.clientHeight/2;
y = y>0 ? -y : 0;
this.scrollto(this.getX(),this.getY(),x,y);
}
this.scrollto = function(x0,y0,x1,y1)
{
if(x0==x1 && y0 ==y1)
{
this.MoveStop();
return;
}
var x = Math.abs(x0-x1);
var y = Math.abs(y0-y1);
var s = Math.sqrt(x*x+y*y);
this.movespeed = s>100 ? 30 : 10;
var sx = this.movespeed * (x/s);
var sy = this.movespeed * (y/s);
x0<x1 ? x0 += sx : x0 -= sx;
y0<y1 ? y0 += sy : y0 -= sy;
if(x<sx)
x0 = x1;
if(y<sy)
y0 = y1;
this.setPos(x0,y0);
this.minimap.AreaMove(-x0*this.minimap.zoomX, -y0*this.minimap.zoomY);
if(x0==x1 && y0 ==y1)
{
this.MoveStop();
return;
}
this.mapmovetimer = window.setTimeout(this.owner+".scrollto("+x0+","+y0+","+x1+","+y1+")",100);
}
this.MoveStop = function()
{
window.clearTimeout(this.mapmovetimer);
this.mapmovetimer = null;
}
this.DelMap =function() {
//this.mapTable.removeChild(this.mapTable);
//this.mapcontainer.removeChild(this.mapcontainer);
this.map.parentNode.removeChild(this.map);
}
}
map里边第一个变量应该是地图的src 但是其他都代表什么呢 ? |
|