getKey-method

1 reply [Last post]
Offline
Joined: 02/24/2011

Hi,
currently I´m trying to solve all the lessons on these sites. First of all: Thanks for such a great work!
 
Now to my question:
It`s about the Game class in Lesson 3++ .
I´m wondering why you use the env.getKey() method instead of the env.getKeyDown() method, which would make the movements more fluent.
 
Greetings,
dolp

Offline
Joined: 12/13/2010
There's no particular reason

There's no particular reason for the use of env.getKey() method instead of env.getKeyDown().  The one thing that I can think of is that using the getKey() method makes implementing one-time event a little easier.  For example, if you need to implement a "jump" function using the space-bar, it makes sense to detect that using getKey() as jump happens only once.  If you use the getKeyDown() method for jump, it would keep executing the "jump" code as long as the space bar is held down.
BTW, welcome to the env3d community!