Go to the next character

This sounds like a simple enough thing to do, but I can't seem to figure it out. Say you have a char 'a' and you want it to go to 'b' if you push right. How do you do that?
[177 byte] By [XNARockstar] at [2007-12-26]
# 1
Take your pick:

char next = (char)((int)'a' + 1);

or

char next = (char)('a' + System.Convert.ToChar(1));

leclerc9 at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2
Gracias
XNARockstar at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
If you're doing this to allow people to enter their names/initials onto a leaderboard you may actually want to keep the permitted characters in an array and simply update an index to it.

The reason for all this weirdness is that it allows you to more easily localise your game for areas which may have different allowable character sets etc., you simply replace the character array with a different array of characters and you're away.

Molt at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4
You might also want to take a look at the XGameLineInput component. It shows how to do text input without actually typing keys on the keyboard. You can detect Key.Left, Key.Right and Key. Return presses and make calls to the Left(), Right(), and Select() methods.
ProfEclipse at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5

Good point, Molt. I noticed that there are a lot of gaps, so I'll add that in once I figure out what each character value is.

The XGameLineInput would have been nice to know about before but since I already put in my own code, I'll just add to what I've got.

XNARockstar at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...