onKeyPress running code for a split second, then reverting
Version
master
What browsers are you seeing the problem on?
Chrome, Firefox, Safari, Microsoft Edge, Other
What happened?
Hello, I'm currently trying to create a starting menu ui for my game and realized that when I'm using the onKeyPress function, it'll only execute the code for a split second then revert back to the sprites original scale, position, or anything like that. Any fix, or is this a problem with kaboom?
What's the expected behavior?
It should permantly change what I specify on the sprite without reverting back, unless specified to.
Minimum reproducable code
kaboom()
const exampleSprite = add([
sprite("example"),
pos(width()/2, height()/2),
scale(1),
origin("center"),
]);
onKeyPress("space", () => {
if (selected == startButton) {
exampleSprite.scale = 2
}});
Live demo
https://BradleyWon.faze-wheezit.repl.co
Hi!
I wasn't able reproduce your issue: Replit demo.
Please make sure that you are not accidentally resetting your components in any of your update or event handlers such as onUpdate(), onDraw(), onStateEnter(), onStateLeave(), or onStateUpdate().
Reopen if issue still