Posted By
|
Message
|
JoeGP
Registered 02/07/2012 21:24:42
Points 82
|
5th February, 2013 at 05/02/2013 22:46:41 -
Hey. I'm using the Platform Movement object, and while I got my basic engine to be pretty much how I'd like it to be, I noticed that if you press both left and right at the same time the character is immediately stopped dead in his tracks, no matter how much momentum he had built up. I've tried a few things to try to get this to stop happening but can't quite figure it out. Any ideas? Thanks a lot!
For reference, here's the game: http://joegp.com/taco1-2/
http://www.JoeGP.com
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
6th February, 2013 at 06/02/2013 20:16:39 -
Easy, either ignore both keys, or let the last key pressed take precedent.
You could add a new object called "InputController" that stores values that represent the last key pressed.
Upon pressing "left"
-Set value "input" of "InputController" to 1.
Upon pressing "Right"
-Set value "input" of "InputController" to 2
If key "left" *is not* being pressed
& If key "right" *is not* being pressed
-Set value "input" of "inputController" to 0
Then use the value of "input" of the "InputController" to determine which input is selected.
n/a
|
JoeGP
Registered 02/07/2012 21:24:42
Points 82
|
6th February, 2013 at 06/02/2013 22:16:52 -
Genius. Thanks a lot!
http://www.JoeGP.com
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
7th February, 2013 at 07/02/2013 19:08:57 -
Always do it this way for all your games. Create a object to manage inputs. This makes it easier to build custom control schemes later. Esp with touch screen based games.
n/a
|
JoeGP
Registered 02/07/2012 21:24:42
Points 82
|
8th February, 2013 at 08/02/2013 20:07:42 -
Yeah, I was just thinking about how it would make it easier to manage touch screen movement. Cool!
http://www.JoeGP.com
|
|
|