class Shape extends Map {
//Collision priority represents with Shape should test collision
//Collision will be testing with the shape with higher priority
constructor(type, params, collisionPriority=0) {
super(setProperties({
type: type,
collisionPriority: collisionPriority
}, params), true);
}
get type() {
return this.get("type");
}
get collisionPriority() {
return this.get('collisionPriority');
}
}
class RegularPolygon extends Shape {
constructor(numSides, size, vertices=null) {
super("regularpolygon", {
numSides: numSides,
size: size,
vertices: vertices
});
}
get numSides() {
return this.get("numSides");
}
get size() {
return this.get("size");
}
}
Unnecessary code is removed from the classes. setProperties
will add properties in params
to the object passed to super
.
extendable.js:44 Uncaught TypeError: Cannot set property size of [object Object] which has only a getter
at extendable.js:44
at Array.reduce (<anonymous>)
at extendable.js:43
at e.u.__wrapImmutable (createExtendable.js:53)
at e.a [as constructor] (extendable.js:55)
at e (Shape.js:11)
at new e (RegularPolygon.js:9)
I'm looking into fixing it, but I figure it will be easier for someone else. Maybe there's a better way to do what I'm looking for as well.