I've done a bit of XNA work, and I'm now trying to work in MonoGame. Previously, for all my input and output needs, I used Microsoft.Xna.Framework. I'm now trying to make one version of my game to deploy on as many platforms as possible (excluding, at the moment, touch interfaces), but I don't know what I should be doing regarding the mouse, for example.

Does MonoGame make Microsoft.Xna.Framework platform-agnostic or do I have to use other frameworks and switch between them depending on the platform?

有帮助吗?

解决方案

MonoGame is designed to make it easy to port your game to other platforms, you shouldn't need to use any other frameworks to achieve that goal. However, it's not as simple as simply recompiling the code for each new platform.

For the most part all of your code will remain the same, but you'll need to put together a project for each platform and link all of the code files in each one. I won't go into detail about this, but I'll just say that you can do it and it's not that difficult.

Now, what you will find is that you may have to write some platform specific code to handle device specific stuff like screen scaling and input handling. What exactly you need to do will depend on your game, so I can't really explain that in detail either.

To make your life easier, it can be helpful to think about how your game is going to work on other platforms and write your code accordingly. For example, a touch on mobile device is very similar to the click of a mouse so you could wrap this functionality in a method of your own to minimize the code changes required when porting. On the other hand, some things you can do with a mouse simply don't work on touch interfaces, like right click, and hover. Similarly, touch interfaces have commonly used gestures that don't really map to a mouse on a PC like long press, swipe and pinch.

So the short answer is, you don't HAVE to do anything special, but you should at least think about it if you plan to port your game in the future.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top