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

88
Vistas
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 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