Estoy creando un juego html donde genero plataformas al agregarlas manualmente a las plataformas de matriz, por lo tanto, creé una función que agregará objetos a esa matriz. Pero arroja un error:
canvas.bundle.js:230 TypeError no detectado: indefinido no es iterable (no se puede leer la propiedad Symbol(Symbol.iterator))
let generation = ( object, array, image, y ) => { array = [... array, new object({ x: LastPos, y, image })] LastPos = image.width + Math.floor(Math.random() * 1000) } generation(Platform,platforms,platformImage,470)la ejecución de la función estará en el bucle
El objeto PS a generar es la clase:
class Platform { constructor({x, y, image}) { this.position = { x, y } this.image = image this.width = image.width this.heigth = image.height } draw() { c.drawImage(this.image, this.position.x, this.position.y) } }