Sunday, August 4, 2013

Bunny Hunters Online: The Asset Project

The Bunny Hunters code will be organized into a set of projects.  There will be one shared Asset project that all platforms references, and an individual project for each platform.  All these projects will be contained in a single master Solution.

After spinning up Visual Studio 2012, the first thing to do is create the solution.  You do this by clicking "new project" on the left which will bring up this dialog:

Open "other project types" on the left and select Visual Studio Solution.  In the center, click on Blank Solution.  Give it a name in the "Name:" field below, make sure the location is where you want your project to be (default is the standard VS2012 project directory), and click OK.

You should now see the VS2012 workbecnh, on the right side will be the Bunny Hunters Online solution:

This will contain all the projects.  To begin with, we need to create a Content Project for the Assets.  Right click on the solution and select add->New Project.

This will take you back to the new project dialog.  This time select MonoGame and MonoGame Content Project.  Give it a name of BHO Assets and click OK.

From time to time you will see this warning dialog for VS2012.  Its a bit of silliness on the part of the VS2012 developers and is safe to ignore, so click OK.

You should now see two projects in your solution: BHO Assets and BHO AssetsContent (Content).   If you open the "Content References" in BHOAssets you should see a reference to BHO_AssetsContent.

Unfortunately, the template doesn't create this reference quite correctly (note the little yellow icon to the left.)  Trying to build assets with this project as is can be immensely frustrating as it silently fails.  To fix this, first right click on the BHO_AssetsContent reference and select "remove".  Then, right click on the Content References folder itself and select "Add Content Reference".  A dialog will pop up with BHO AssetsContent already selected.  Just click OK.

If you did all that properly your solution should now look like this. (Note that there is no longer a little yellow symbol to the left of the BHO AssetsContent reference):

The next thing to do is to add the assets.  The assets can be downloaded as a zip file from  Download them and unzip them in a temporary directory.  Then go back to VisualStudio2012.   Right click the BHO AssetContent project and select add->existing item.

In the dialog that comes up, navigate to where you unzipped the assets, select them all, and click Add.

Your content project should now contain all the assets and look something like this:

Its almost ready to test.  However, by default the content project comes up set to build for Android.

As a convenience, lets reset it for windows.  You do this by clicking the arrow to the right of the word Android and selecting Windows on the drop down.

Now its ready to test.  Go to the Build option on the menu bar and select Build Solution.

It should crank for a bit, then say "Build succeeded" in the bottom left corner of the VS2012 window.  To see the results, first navigate to where you created your Bunny Hunters Online solution.  (If you didn't change it, its in the default VS2012 projects directory.)

Now, drill down to BHO Assets->BHO Assets->bin->Windows->Content. In that directory you should see a list of files with the extension xnb.  These are the processed assets that the game will actually use.  They are compressed to make better use of space on limited memory devices.

Thats it!  You know have a working, cross platform asset project.  Next blog, we will make use of it to start creating a Windows Store 8 game.

No comments:

Post a Comment