react连连看

时间:2021-08-02 05:36:23

 

// Math.floor(t * Math.random());
var isInclude = function (array, element) {
let alen = array.length;
for (let i = 0; i
{num}

);
}
});

var GameTable = React.createClass({
getInitialState: function () {
return this.props;
},
render: function () {
let blocks = this.props.blocks;
let selectedGrid = this.props.selectedGrid;
let _lines = [];
let _line;
let attr = {};
for (let i = 0; i );
}
_lines.push(

{_line}

);
}

return (

{_lines}

);
}
});
//*/

var GameBox = React.createClass({
getInitialState: function () {
let [lines, remaining] = this.getBlocks(this.props.row, this.props.col, this.props.pairs);
return {
...this.props,
blocks: lines,
remaining: remaining,
selectedGrid: [],
isGaming: true,
maxCornerLen: 2
};
},
componentDidMount: function () {
},
componentWillUnmount: function () {
},
getRandomPositions: function (row, col, pairs, blocks) {
let i, j;
let _tmpNums = [];
for (i = 0; i = ps.length) {
//
}
if (ps[n]) {
blocks[i][j].num = ps[n];
blocks[i][j].bgc = getColor(ps[n]);
}
n++;
}
}
let remaining = pairNum * pairs;
return [blocks, remaining];
},
getBlocks: function (row, col, pairs) {
let line = [];
let lines = [];
for (let i = 0; i 0)
return true;
return false;
},
doRemove: function (rc1, rc2) {
let toRemoves = this.findPath(rc1, rc2);
//console.log(toRemoves);
this.setState({isGaming: false});

let _this = this;
let flashSpeed = 200;
let _len = toRemoves.length;
for (let i = 0; i = row || rc[1] = col);
},
findDirectRcs: function (oriRcs, rc2) {
let {row, col, blocks} = this.state;
let retRes = [];
let hs = {};
let _rc, _ds, _rc2;
for (let i = 0; i

还剩{this.state.remaining}对

{this.state.msg}

高:
宽:
每个数字有几对: