I'm storing keypresses detected from love.keypressed() into the var "KEY" (for other functions), but only need it for 1 frame, and so I added "KEY = nil" at the end of love.update.
So, is it better to have "KEY = nil" there, or "if KEY then KEY = nil end"? Would there be a simpler or "official" way to keep values only for a single frame?
Thanks!
What's best to keep a value for only 1 frame?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
What's best to keep a value for only 1 frame?
Currently working on game music...
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: What's best to keep a value for only 1 frame?
KEY = nil is fine, nothing bad happens if you nil something that was nil already.
That said, with this method, you can only store one specific key; if you'd press multiple during one frame, only one of them would be saved.
That said, with this method, you can only store one specific key; if you'd press multiple during one frame, only one of them would be saved.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: What's best to keep a value for only 1 frame?
Guess I'll use a table for that then... hopefuly, there're not many places in my game where I have to change this (so far...)
Currently working on game music...
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests