呵呵,挺好的
主要思路就是修改className的背景图片
下棋的背景是
.D0 { background-image: url('http://www.wtostar.com/go/D0.gif'); }
.D1 { background-image: url('http://www.wtostar.com/go/D1.gif'); }
.C0 { background-image: url('http://www.wtostar.com/go/C0.gif'); }
.C1 { background-image: url('http://www.wtostar.com/go/C1.gif'); } 方法中主要是Play方法,中间调用Fill方法Fill: function(dot, going) //填充棋子的方法
{
if ( dot == undefined )
this.className = this._backStyle //无子,就设置为背景式样。这里是初始化的背景
else
this.className = (going ? "C" : "D") + dot; //这里是下棋一下黑一下白 dot则是是不是新子
this.dot = dot; //保存棋子状态
},
Play: function() //行棋方法,由onclick事件触发
{
if ( this.dot == undefined ) //无子
{
var deads = this.Kill(current^1); //计算可以杀死的子
if (deads.length == 1 && this == rob) return; //打劫状态
for(var i=0; i <deads.length; i++)
deads[i].Fill();
if(i==1)
rob = deads[0] //记录打劫位置
else if (i>0 || !this.Tight(current))
rob = null //清打劫位
else return;
sound.play(); //落子有声!
var step = Tracks[Tracks.length-1];
if(step) step.site.Fill(step.site.dot);
this.Fill(current, true); //填入当前该填的子 //这部分是下棋的主要部分
Tracks.push( new Step(this, deads) );
current ^= 1; //用1来异或,正好反转黑白棋子。
};
//alert(Tracks[Tracks.length-1].Step());
},
主要思路就是修改className的背景图片
下棋的背景是
.D0 { background-image: url('http://www.wtostar.com/go/D0.gif'); }
.D1 { background-image: url('http://www.wtostar.com/go/D1.gif'); }
.C0 { background-image: url('http://www.wtostar.com/go/C0.gif'); }
.C1 { background-image: url('http://www.wtostar.com/go/C1.gif'); } 方法中主要是Play方法,中间调用Fill方法Fill: function(dot, going) //填充棋子的方法
{
if ( dot == undefined )
this.className = this._backStyle //无子,就设置为背景式样。这里是初始化的背景
else
this.className = (going ? "C" : "D") + dot; //这里是下棋一下黑一下白 dot则是是不是新子
this.dot = dot; //保存棋子状态
},
Play: function() //行棋方法,由onclick事件触发
{
if ( this.dot == undefined ) //无子
{
var deads = this.Kill(current^1); //计算可以杀死的子
if (deads.length == 1 && this == rob) return; //打劫状态
for(var i=0; i <deads.length; i++)
deads[i].Fill();
if(i==1)
rob = deads[0] //记录打劫位置
else if (i>0 || !this.Tight(current))
rob = null //清打劫位
else return;
sound.play(); //落子有声!
var step = Tracks[Tracks.length-1];
if(step) step.site.Fill(step.site.dot);
this.Fill(current, true); //填入当前该填的子 //这部分是下棋的主要部分
Tracks.push( new Step(this, deads) );
current ^= 1; //用1来异或,正好反转黑白棋子。
};
//alert(Tracks[Tracks.length-1].Step());
},
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货