[SOLVED] Locking user key inputs?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
SunnyCloudySkies
Prole
Posts: 5
Joined: Sun Aug 16, 2020 9:48 am

[SOLVED] Locking user key inputs?

Post by SunnyCloudySkies »

Hi there forums! I'm relatively new to lua and love2d, and I'd like some help!

I've made a player class which allows players to control sprites on screen with arrow keys. Using this player class, I have made a cutscene that moves the sprite across a map. However, if the user presses any of the arrow keys while the sprite is moving during the cutscene, the user keypresses override the animation programmed into the cutscene and the user can change animations (but not the movement of the sprite).

Thus, as this is only triggered while the person inputs a keypress, is there any way to lock keypresses for a certain period of time until the cutscene is over?

Or do you think it would be better to make an entirely new class to handle player cutscenes like this?

Thanks in advance! :awesome:
Last edited by SunnyCloudySkies on Sat Aug 22, 2020 12:22 pm, edited 1 time in total.
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Locking user key inputs?

Post by sphyrth »

There are several ways to tackle this: A combination of a State Machine + Making Input Detection Separate from the Animation would be my personal choice.

In your case, you seem to have your animation code tied to your Inputs. Try transfering that into the movement code (since that doesn't get affected).

Some people might help you better by putting out a working sample of main.lua file for us to see.
SunnyCloudySkies
Prole
Posts: 5
Joined: Sun Aug 16, 2020 9:48 am

Re: Locking user key inputs?

Post by SunnyCloudySkies »

sphyrth wrote: Sun Aug 16, 2020 10:14 pm There are several ways to tackle this: A combination of a State Machine + Making Input Detection Separate from the Animation would be my personal choice.

In your case, you seem to have your animation code tied to your Inputs. Try transfering that into the movement code (since that doesn't get affected).

Some people might help you better by putting out a working sample of main.lua file for us to see.

Oh, thanks for your input! :awesome:
I took your advice of transferring the animation code into the movement code and it works like a charm. Next time I post a question, I'll be sure to post my code too.

Thanks! :megagrin:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests