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!
[SOLVED] Locking user key inputs?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Sun Aug 16, 2020 9:48 am
[SOLVED] Locking user key inputs?
Last edited by SunnyCloudySkies on Sat Aug 22, 2020 12:22 pm, edited 1 time in total.
Re: Locking user key inputs?
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.
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.
-
- Prole
- Posts: 5
- Joined: Sun Aug 16, 2020 9:48 am
Re: Locking user key inputs?
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!
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!
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests