kaboom icon indicating copy to clipboard operation
kaboom copied to clipboard

onKeyPress running code for a split second, then reverting

Open ibmoth opened this issue 3 years ago • 1 comments

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

ibmoth avatar May 12 '22 17:05 ibmoth

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().

Lassi-Koykka avatar May 13 '22 09:05 Lassi-Koykka

Reopen if issue still

lajbel avatar Oct 04 '22 16:10 lajbel