Below is the class piece which we need to store in an object and save but when we try to do it using localstorage.setitem we are getting a type error.
class Piece {
constructor(type, game){
//convenience
this.Game=game;
if (!type) type='';
type=type.toUpperCase();
this.name=type;
//every piece has its shape as a bitmap and other
//properties describing its presentation
switch (type){
case 'F':this.trayPosition=0;
this.bitMap=[
[0,0,0,0,0],
[0,0,1,1,0],
[0,1,1,0,0],
[0,0,1,0,0],
[0,0,0,0,0]
]; break;
case 'I':this.trayPosition=1;
this.bitMap=[
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0]
]; break;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…