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);
}
});