Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


What key is this ~ in XNA Keys


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 FantasyVII   Members   -  Reputation: 342

Like
0Likes
Like

Posted 04 November 2012 - 05:56 PM

Hello everyone,

I went to the MSDN try to find the enum name for this key ` but I can't find it. So do guys know what is the key name?

http://msdn.microsof...input.keys.aspx

example keyboardState.IsKeyDown(Keys. ?!!!)

Posted Image

Edited by FantasyVII, 04 November 2012 - 05:57 PM.


Sponsor:

#2 zacaj   Members   -  Reputation: 643

Like
2Likes
Like

Posted 04 November 2012 - 05:58 PM

~ is a tilde

#3 FantasyVII   Members   -  Reputation: 342

Like
0Likes
Like

Posted 04 November 2012 - 07:10 PM

~ is a tilde


thanks :)

#4 FantasyVII   Members   -  Reputation: 342

Like
0Likes
Like

Posted 04 November 2012 - 07:18 PM

one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.

public void Update()
{
	 newState = Keyboard.GetState();

	 if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
		  Enable = true;

	 if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
		  Enable = false;

	 oldState = newState;
}

Edited by FantasyVII, 04 November 2012 - 07:24 PM.


#5 Xanather   Members   -  Reputation: 712

Like
1Likes
Like

Posted 05 November 2012 - 12:02 AM

one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.

public void Update()
{
	 newState = Keyboard.GetState();

	 if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
		  Enable = true;

	 if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
		  Enable = false;

	 oldState = newState;
}


The following code should work...
[source lang="csharp"] public KeyboardState keyboardstate; public KeyboardState keyboardstateprev; public bool enabled; protected override void Update(GameTime gameTime) { keyboardstate = Keyboard.GetState(); if (keyboardstate.IsKeyUp(Keys.Enter) && keyboardstateprev.IsKeyDown(Keys.Enter)) { if (enabled) { enabled = false; } else { enabled = true; } } keyboardstateprev = keyboardstate; base.Update(gameTime); }[/source]

Edited by Xanather, 05 November 2012 - 12:13 AM.


#6 FantasyVII   Members   -  Reputation: 342

Like
0Likes
Like

Posted 05 November 2012 - 08:18 AM


one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.

public void Update()
{
	 newState = Keyboard.GetState();

	 if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
		  Enable = true;

	 if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
		  Enable = false;

	 oldState = newState;
}


The following code should work...
[source lang="csharp"] public KeyboardState keyboardstate; public KeyboardState keyboardstateprev; public bool enabled; protected override void Update(GameTime gameTime) { keyboardstate = Keyboard.GetState(); if (keyboardstate.IsKeyUp(Keys.Enter) && keyboardstateprev.IsKeyDown(Keys.Enter)) { if (enabled) { enabled = false; } else { enabled = true; } } keyboardstateprev = keyboardstate; base.Update(gameTime); }[/source]


thank you very much it works :D




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS