js写法
this.check = function(shape, x, y, d){
var r1=0,r2='N';
for(var i=0;i<8;i+=2){
if(shape[i]- -x < 0 && shape[i]- -x <r1)
{r1 = shape[i]- -x;}
else if(shape[i]- -x>=this.width && shape[i]- -x>r1)
{r1 = shape[i]- -x;}
if(shape[i+1]- -y>=this.height || this[shape[i]- -x- -(shape[i+1]- -y)*this.width])
{r2='D'}}
if(d=='h'&&r2=='N')return r1>0?r1-this.width- -1:r1;
else return r2;}
函数中的“shape[i]- -x”怎么理解??跪求!
------解决方案--------------------说明js连变量前加负号都识别,厉害了
------解决方案--------------------