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

91
Visualizações
onKeyPress causing moveTo to not move an object permanently

I'm trying to make a game in kaboomjs right now and I'm on the starting menu and I've come across a problem where the object that indicates which button is selected is going right back to its original position when using the onKeyPress or onKeyDown functions. Whenever I use moveTo outside of the onKeyPress or onKeyDown blocks it'll stay at the position, but it seems to just go to the new position for a split second when I use onKeyPress or onKeyDown to detect if the down arrow is being pressed. Anybody know why this is or should I open an issue on the kaboomjs github page?

let selected = startButton;

const selArrow = add([
  sprite("selArrow"),
  pos(selected),
  "ui",
  scale(1.5),
  origin("center"),
]);

onKeyPress("down", () => {
  if (selected == startButton) {
    selected = optionsButton;
    selArrow.moveTo(selected.pos.x-10,selected.pos.y+5);
  } else {
    selected = startButton;
    selArrow.moveTo(selected.pos.x-10,selected.pos.y+5);
  }
});
about 4 years ago · Juan Pablo Isaza
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