2

The problem is that I'm developing a game for Windows Phone 7.1/8/8.1 (With Xna and Visual studio 2012 Express), but I prefer to do every test on my pc as a Windows "desktop" application. It works very fine: I created the project of a shared library so that the changes in the Windows project is seen by Windows phone project.

The only problem is for my input class... With Windows I need to take input from keyboard, with Windows phone from touch. Usually I just commented in/out some pieces of code to test on both platforms. But It's very boring.

So I thought to use heredity, using as base class "InputManager", as derived "KeyboardInput" and "TouchInput".

I would like to instantiate the InputManager class with a preprocessor directive based on which system I am compiling for:

#if WP
input_manager_ = new TouchInput();
#endif

#if Windows
input_manager_= new KeyboardInput();
#endif

But I didn't find googling which are the right directives!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Francesco Bonizzi
  • 5,142
  • 6
  • 49
  • 88
  • 2
    You will have to create your own in your config, e.g. http://stackoverflow.com/questions/2923210/conditional-compilation-and-framework-targets – Matthew Watson Jun 02 '15 at 10:01
  • 1
    Depending on what else you target, maybe this could be of use: [Conditional Compilation](https://msdn.microsoft.com/en-us/library/windows/apps/jj714084(v=vs.105).aspx). It seems like their approach is to determine if Windows is being targeted, and identify the phone case in the else. (At the bottom). – Élie Jun 02 '15 at 11:27

0 Answers0