• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Arrow for direction, Shift for run

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there way to have 2 keys being pressed at the same time and be able to have the prior action along with it?

I know that if you press down both keys at the same time, the effect will occur.

But I want to be able to walk a direction for an amount of time, then press and hold down the Shift key and have the character start running.



Any help?
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
KeyEvent has an isShiftDown() method.

does that help?

 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't you add an action for Detect_Initial_Press_Only for the Shift key that increases your speed and then On_Key_Release decrese the speed back to a walking speed? OR

While Shift.isPressed() speed = RUN_SPEED otherwise speed = WALK_SPEED

I would try one of those as a work around, I have never actually tried to detect multiple keys being pressed at once and have them both firing off actions. I'm sure it's possible though, fighting games seem to be all about multi-button mashing. Let us know if you can't get anything working and I'll try and play with some code to experiment.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic