Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 02-17-2007, 01:00 PM   #1 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,149
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default Switching Keyboard Input

I'm trying to make a switch statement for keyboard input:
Code:
        switch (newState.IsKeyDown(Keys))
        {
            case Keys.Up: spritePosition.Y++; break;
            case Keys.Down: spritePosition.Y--; break;
            case Keys.Right: spritePosition.X++; break;
            case Keys.Left: spritePosition.X--; break;
        }
Error:
Code:
'Microsoft.Xna.Framework.Input.Keys' is a 'type' but is used like a 'variable'
I can't stand using if/else statements when I have the ability to use a switch...so...any ideas? or is this even possible?
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline   Reply With Quote
Old 02-17-2007, 01:45 PM   #2 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
Default

IsKeyDown sounds like it should return boolean not the keys that are down....
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 02-17-2007, 01:54 PM   #3 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

Use a KeyDown event, and then make the switch variable e.KeyCode, and use each key's numerical value as the cases.
WarAngel is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5