Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
No se pueden leer las propiedades de un JavaScript indefinido (leyendo 'Actualizar')

Estoy tratando de hacer un GameEngine TypeScript muy básico, pero no puedo leer las propiedades de un error indefinido y no entiendo por qué.

Este es el error:

 Uncaught TypeError: Cannot read properties of undefined (reading 'Update') at u (TSEngine.js:24:14)

Mi código antes de convertir a javascript:

 import Vector2 from "./class/Vector2.js"; import Square from "./class/Square.js"; export default class TSEngine { indexFileName: string; s: Square; v: Vector2; constructor(indexFileName: string) { this.indexFileName = indexFileName; } Vector2(x: number, y: number): Vector2 { this.v = new Vector2(x, y); return this.v; } Square(position: Vector2, size: number, color: string): Square { this.s = new Square(position, size, color); return this.s; } Update(toUpdate: () => void): void { if(toUpdate) { toUpdate(); } } u(deltaTime: number): void { this.Update(() => {}); requestAnimationFrame(this.u) } }

Mi código después de convertir a javascript:

 import Vector2 from "./class/Vector2.js"; import Square from "./class/Square.js"; export default class TSEngine { constructor(indexFileName) { this.indexFileName = indexFileName; } /*getBasePath(): string { return this.indexFileName; }*/ Vector2(x, y) { this.v = new Vector2(x, y); return this.v; } Square(position, size, color) { this.s = new Square(position, size, color); return this.s; } Update(toUpdate) { if (toUpdate) { toUpdate(); } } u(deltaTime) { this.Update(); /// it shows me the error here requestAnimationFrame(this.u); } }

He intentado poner la función 'Actualizar' arriba pero no hace nada

Editar Estoy tratando de usar esta función así:

 Engine.Update(() => { // the things to update })

Puse un archivo console.log en la función Engine.Update pero solo se mostró una vez.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!