Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

324
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda