I am working on a game in VS Code, I ran into this error and don’t know what it means or how to resolve it.
VS Code error:
Uncaught e.findIdx is not a function
at lvl1 (main.ts:105:1)
at inline (main.ts:54:57)
at runButtonEvents (pxt_modules/game/controllerbutton.ts:237:9)
at inline (pxt_modules/game/controllerbutton.ts:266:45)
at inline (pxt_modules/base/eventcontext.ts:32:59)
Make Code Website error:
e.findIdx is not a function
at lvl1 (line 118)
at inline (line 57)
at inline (line 6)
Code of interest:
let enemys: any =
let enemyNumber: number
for (let i: number = 0; i < 3; i++) {
// enemy setup
enemyNumber = i
enemys[enemyNumber] = sprites.create(assets.imageBasic Enemy
, SpriteKind.Enemy)
enemys[enemyNumber].vx = -30
// enemy movment setup
game.onUpdateInterval(200, function () { // evry 0.2 sec
if (enemys[enemyNumber].vx == 30) { // if the player is traveling right
if (!(tiles.tileAtLocationIsWall(enemys[enemyNumber].tilemapLocation().getNeighboringLocation(CollisionDirection.Right).getNeighboringLocation(CollisionDirection.Bottom)))) { // if the tile to the below and to the right of the sprite is not a wall
enemys[enemyNumber].vx = -30 // make the sprite turn the other direction
}
} else {
if (!(tiles.tileAtLocationIsWall(enemys[enemyNumber].tilemapLocation().getNeighboringLocation(CollisionDirection.Left).getNeighboringLocation(CollisionDirection.Bottom)))) { // if the tile to the below and to the right of the sprite is not a wall
enemys[enemyNumber].vx = 30 // make the sprite turn the other direction
}
}
})
}
tiles.placeOnTile(enemys[1], tiles.getTileLocation(10, 14))
tiles.placeOnTile(enemys[2], tiles.getTileLocation(20, 14))
tiles.placeOnTile(enemys[3], tiles.getTileLocation(29, 11))
The Git-Hub repo and branch I am working on can be found Here