'ERROR TypeError: this.renderMap is not a function
I'm tryin' to execute an angular project with fps creating a liveCyle that is triggered for each interval. The cycle is composed by three functions, for each cycle the console returns
ERROR TypeError: this.renderMap is not a function/ line 81
at console, which is the first function, I searched everywhere but none of previous questions helped me, someone know?
imports ...
@Component({
...
})
export class SnakeGameComponent implements OnInit {
@ViewChild("dynamicTerrain", {static: false})
dynamicTerrain: HTMLCanvasElement | undefined;
imageRef: string = './assets/img/lime.png';
onTouchWallKill: boolean = false;
defaultFruitnumber: number = 5;
fruitsInMap: Array<any> = [];
frequency: boolean = false
paused: boolean = false;
foundingSnake: Snake = new Snake([{nextBody: 'n', x: 8, y: 4},
{nextBody: 'n', x: 8, y: 3},
{nextBody: 'n', x: 8, y: 2}], 's')
// @ts-ignore
headPositionX: number = this.foundingSnake.bodyArray[0].x;
// @ts-ignore
headPositionY: number = this.foundingSnake.bodyArray[0].y;
mapping: CanvasRenderingContext2D | null = null
ngOnInit(): void {
...
}
@HostListener('window:load') onload() {
setInterval(this.liveCyle, 1000/20)
}
public liveCyle() {
this.frequency = !this.frequency;
if (!this.paused) {
this.renderMap(); <---------- line 81
this.runSnake();
this.renderSnake();
}
}
public renderMap(): void {
...
}
public runSnake(): void {
...
}
public renderSnake(): void {
...
}
-------> Rest of code...
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
