I've been trying to create a reusable library to use across multiple games, so I created a Windows Game Library with my reusable classes, however I can't seem to figure out how to use the library in my game project. I've tried adding a reference to the .dll file to my game project references and also tried adding the project to my game solution (I was just screwing around trying to get it to work), but I'm not even entirely sure that the Windows Game Library is the project type I should be using.

In short: Is the Windows Game Library the appropriate project type to create a reusable, multi-game library? And, How do you use the classes within that library in an XNA Windows Game project?

有帮助吗?

解决方案

Your on the right track, you need to have them in the same project, and have the game reference the project (not .dll) directly. To do this, go to your main game, select Add Reference.

When the dialog pops up, find Solution, and under it Projects. You should see your library in there, tick the checkbox and it will be referenced.

https://i.imgur.com/U88z0SJ.png

As far as the solution layout goes, and how to use the library in your game, I created a quick illustration:

https://i.imgur.com/VHQM0Oc.png

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