The Daily Click ::. Forums ::. Klik Coding Help ::. Keyboard Key Release need help
 

Post Reply  Post Oekaki 
 

Posted By Message

Rasmus Knudsen



Registered
  21/10/2008
Points
  14
11th November, 2008 at 10:52:24 -

Hello TDC.
Im having a problem with some movement in a game.
I need a way to make an event that occour when the user releases a certain key.
I only know theres an event when the user presses the key, but theres no event for when the user releases the key again.

I could ofcourse negate the key press so when the key is not pressed, but i need the event to only occour once everytime the user releases the key.

Anyone think of an easy way to do this?


Thanks.
Souley

Image Edited by the Author.

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
11th November, 2008 at 10:58:25 -

I think Construct does it much more easily You could try something like this:

Let's say you're pressing X.

On press X:
Set flag 1 on.

(Negate) On press X AND Flag 1 is ON:
Set Flag 1 OFF.
(The event that happens when you release the key)


Not sure if that works, but you could try.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Rob Rule

Rusten Crating

Registered
  22/12/2007
Points
  532
11th November, 2008 at 17:20:03 -

I'm on MMF all day, so just tried out Muz's suggestion for you. Doesn't seem to work, I'll have a play myself.

 
It'll all blow over.

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
11th November, 2008 at 17:52:39 -

Yah make sure you use the "Upon Pressing" for the first part, and (Negate) "Repeat While Pressing" for the second part. That would have caused it to malfunction otherwise.

Think of it like this. The Upon Pressing X event will activate only for a single frame when it is pressed, whereas Repeat While Pressing X will activate every single frame the key is held down, including the first one. If you negate the Upon Pressing X event, it will every OTHER frame than the one you pressed the key, and if you negate the Repeat one, it will activate every frame the key is *not* held down.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Rob Rule

Rusten Crating

Registered
  22/12/2007
Points
  532
11th November, 2008 at 18:14:05 -

Oh, of course. The repeat while pressed went right over my head.

Very simple to follow, but seeing as I'd already made it, here's an example of it in action, Rasmus;

http://www.sendspace.com/file/7w9cjy

 
It'll all blow over.

Rasmus Knudsen



Registered
  21/10/2008
Points
  14
11th November, 2008 at 21:13:09 -

Thanks alot everyone. I didnt get it to work exactly that way, but found another way of doing it

Btw its for my MMORPG project, which seems to be going pretty well already.
Loginscreen is done, and now all the movement is done. Its very online-trafic efficient so i can have a huge amount of clients connected simultaneously and walking around chatting with eachother

 
n/a
   

Post Reply



 



Advertisement

Worth A Click