Jump to content
  • Advertisement
Sign in to follow this  
jagguy2

static variables

This topic is 3642 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to get the number of milliseconds i hold down a key The reason being is that if i hold it down for more than 1 sec I will do fire another missile (game play). The problem is that all i get is 31 MS for just a press of the key or a slightly longer press? Basically i am not doing getting the timespan of the keypress. this procure gets called until i let go of the ctrl button where it will remove the key from a list. Dim startt As DateTime = Now Dim endt As DateTime = Now Static mytime As TimeSpan = endt.Subtract(startt) If dict.ContainsKey(Key.Ctrl) Then endt = Now mytime = mytime + endt.Subtract(startt) txt1.Text = txt1.Text & mytime.Milliseconds.ToString For i = 0 To 19 If missile(i).fire = False Then missile(i).y = 0 missile(i).fire = True txt1.Text = txt1.Text & " fire1 " ' mytime = Now.Subtract(Now) ' dict.Remove(Key.Ctrl) Exit For End If Next End If 'this does work Private Sub getKeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs) dict.Remove(e.Key) End Sub

Share this post


Link to post
Share on other sites
Advertisement
If you remove the item from the dict when the key is released, then you should be expecting the dict not to contain the item when you check for a key-release, no?

Share this post


Link to post
Share on other sites
no i dont need to test because it will automatically be deleted from the remove key event. I just need to reset the variable

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!