collinhover / impactplusplus

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.
http://collinhover.github.com/impactplusplus
MIT License
276 stars 58 forks source link

Keyboard input skips a step on the conversation entity #125

Closed Pattentrick closed 10 years ago

Pattentrick commented 10 years ago

Hi @collinhover,

i noticed that pressing a key will skip a conversation step, when i am using the conversation entity, if auto advance is deactivated. If i am on step 1 and press my defined action key to advance the conversation i will end up with step 3.

I think the problem is this part of the code:

https://github.com/collinhover/impactplusplus/blob/dev/lib/plusplus/entities/conversation.js#L1064

Example:

I am on step 1 and i am pressing the action key down, so the else if statement above gets executed and the conversation advances to next step, but after that short moment i will release that action key, and the statement gets executed again so it skips to step 3 (if present) and you just see a very brief flickering step 2.

Could we fix that by removing one of the conditions in that else if statement like this:

javascript // wait for action else if ( ig.input.pressed(this.action) ) {

this.nextStep();

}



Mouse clicks are working fine without the second condition. But i am not sure whats up with touch devices regarding to that. You sure had a reason to check for `pressed` and `released`  
collinhover commented 10 years ago

So skipping the released check fixes it and still works for clicks or keys?

Pattentrick commented 10 years ago

Oops, i meant skipping the release action fixes this.

javascript else if ( ig.input.released( this.action ) ) { this.nextStep(); }



Like that it fixes that issue with clicks and keys. Not sure about touch devices though, but i could test that too later in the afternoon if you like.
collinhover commented 10 years ago

That's okay, touch and mouse are both handled as a tap action, so it should be fine. I'll add this fix shortly, thanks for finding it :-)

Pattentrick commented 10 years ago

You are welcome @collinhover ;-)