Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
5.6.5 Coordinates, Answer In Comments (CodeHS)

The prompt of the assignment is "Write a program that shows the X and Y coordinates of the mouse in a label on the top left of the screen. You should update the values of the coordinates whenever the mouse moves." The basic code I have laid out is:

var pos;

function start(){
    mouseMoveMethod(mousePos);
}

function mousePos(e){
    pos = new Text("((" + e.getX() + "," + e.getY() + ")");
    pos.setPosition(75, 75)
    add(pos);
}

It "works" but it just keeps adding text over top of the new text instead of updating the existing text. I know I'm missing something, but I just cannot figure out what to implement to make it work the way it needs to. I've been stuck for days :(

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I got it!!! I just needed to think smarter LOL

var pos;

function start(){
    pos = new Text(" ");
    pos.setPosition(75, 75)
    add(pos);
    mouseMoveMethod(mousePos);
}

function mousePos(e){
    pos.setText("(" + e.getX() + "," + e.getY() + ")");
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda