Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So after running through tutorials by both Microsoft and www.xnadevelopment.com I feel very confident in my ability to get to work on my first game using the XNA Framework. I've manipulated sprites, added audio, changed game states, and even went a step further to apply the knowledge I had and figure out how to make animations and basic 2-dimensional physics (including impulses, force, acceleration, and speed calculations)

But then shortly into the project I hit a curious bump that I've been unable to figure out.

In wanting to implement menus, pause screens, and several different aspects of play (a "pre-level" prep screen, the level itself, and a screen after the level to review how well you did) I took a look at Microsoft's Game State Management sample. I understood the concept, although it was admittedly quite a lot to take in. Not wanting to recreate the entire concept by scratch (after all- what purpose would that serve?) I tried copying and pasting the sample code into my own ScreenManager class (as well as InputState and GameScreen classes) to try and borrow their ingenuity. When I did this, however, my project stopped compiling. I was getting the following error:

The type or namespace name 'Touch' does not exist in the namespace 'Microsoft.Xna.Framework.Input' (are you missing an assembly reference?)

Having read through their sample code already, I realized that this namespace and every function and class within it could be safely ripped from the code without losing functionality. It's a namespace simply for integrating with touchscreen devices (presumably Windows Phone 7, but maybe also tablets).

But then I began to wonder- how come Microsoft's sample compiled but mine didn't? I copied their code exactly so there must be a setting somewhere that I need to change in Visual Studio in order to correct this. I tried creating a new project as a Windows Phone 7 game rather than a Windows game, however that only forced it to compile to a Windows Phone emulator and denied me the ability to change the resolution and other features which I clearly had the power to do in the sample code.

So my question is simple - how do I properly use the namespace Microsoft.XNA.Framework.Input.Touch?

share|improve this question
    
Did you download the right version for your expected use, that is, Windows/Xbox or Windows Phone? I noticed that there was two separate samples of the tutorials respectively. I just compiled using VS2010 and I had not to remove or modify any of the namespaces. –  Will Marcouiller Mar 8 '11 at 0:01
    
I did download the "WIN XBOX" version, however if you'll look at ScreenManager.cs then you'll notice at the top it has the line using Microsoft.XNA.Framework.Input.Touch. Even though it's not intended for use on Windows Phone 7, it still has support for touchscreen gestures (possibly for tablets running Windows 7?) –  stevendesu Mar 8 '11 at 0:14
    
+1 Interesting, I imported the ScreenManager classes and the Screens classes to my test game project, and I encounter the same as mentioned in your question. Working on it now! =) –  Will Marcouiller Mar 8 '11 at 0:20
    
Had you tried to add the reference to within your project? After having added the Microsoft.Xna.Framework.Input.Touch reference to my project, it compiled fine. –  Will Marcouiller Mar 8 '11 at 0:48
2  
From within Visual Studio, right-click on your project and then Add|Reference, click the .NET tab if it isn't active, then select the Microsoft.Xna.Framework.Input.Touch assembly, it will correct no longer annoy you with the error about "missing reference". –  Will Marcouiller Mar 8 '11 at 2:49
show 1 more comment

1 Answer

up vote 5 down vote accepted

Input.Touch is only available in WinPhone7 projects. You can't use it on Win7. I don't know why the XNA team decided to do this. In the beta, Input.Touch worked on Win7 just fine.

share|improve this answer
4  
Shawn Hargreaves explains it here: blogs.msdn.com/b/shawnhar/archive/2010/09/09/… –  Andrew Russell Mar 8 '11 at 7:21
    
+1 for mentionning this. @Andre Russel: Pretty mice article you got there! Thanks for sharing! =) –  Will Marcouiller Mar 8 '11 at 11:16
    
Good point to mention, and I assume this means all the functions and classes within Input.Touch are now meaningless after compiling, but that doesn't change the fact that adding a reference did make it compile (my original question). For now accepted, but I'd like to see it mentioned that adding a reference makes it compile. –  stevendesu Mar 8 '11 at 19:19
    
@Andrew Russell : Thanks for digging that up. I know I'd seen it somewhere. It makes my own experience seem even more strange, though. –  Blecki Mar 8 '11 at 23:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.