-
Notifications
You must be signed in to change notification settings - Fork 1
/
GetStarted.txt
75 lines (68 loc) · 3.66 KB
/
GetStarted.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
MonoVarmint is a helpful framework for working with MonoGame.
It is:
- open-source (MIT License)
- Provided as a shared-code project (not dll) to simplify distribution
To get started (Windows Desktop Example):
==== STEP 1: Set up the project
- Download the MonoVarmint code from github
- Create a Monogame Shared code project
- This will hold the majority of your code and will be shared among the platform project
- Best practice: Name this the name of your app
- Add these monovarmint shared code projects to your solution:
- VarmintTools
- VarmintWidgets
- Create a MonoGame project for Windows Desktop
- Best Practice: Name this "ForWindowsDesktop"
- Add a reference to the three shared code projects:
- For VS 2017 and later: simply right-click and "add reference", then choose from shared projects
- For VS 2015 or earlier, Unload your monogame for Windows project, edit the csproj file, and Add shared project references
to your monogame project by adding these lines near the other imports (you will have to corret
the relative paths and project names)
<Import Project="..\..\MonoVarmint\Tools\VarmintTools.projitems" Label="Shared" />
<Import Project="..\..\MonoVarmint\Widgets\VarmintWidgets.projitems" Label="Shared" />
<Import Project="..\[Replace with SharedMonoGameProject]" Label="Shared" />
Then Reload your monogame for windows project and make these changes
- Modify the Shared code project:
- Delete the Game1 class
- Copy in MonoVarmint/VarmintWidgets/Templates/GameRunner.cs
- Change the project namespace to be what you want
- Change the namespace in the new GameRunner.cs to match your own
- Modify the ForWindowsDesktop Project:
- Delete the Game1 class
- Delete the Content Folder
- Modify the project namespace to be what you want
- Best Practive [SharedProjectNamespace].ForWindowsDesktop
- Create a new class that inherits from GameRunner
- Best Practice: call it WindowsDesktopGameRunner
- Modify Program class to reference your new class instead of Game1
- At this point, you should be able to run the windows app and see a default screen with some
instructions on what to do next.
==== STEP 2: Add your first screen
- In the shared code project:
- Create a folder called "Layout"
- Copy "SimpleScreen.vwml" from VarmintWidgets/Templates to your Layout folder
- rename it to "MainScreen.vwml"
- Right click on MainScreen.vwml and select "Properties"
- Change Build action to "Embedded Resource"
- Notes:
- .vwml files can be saved anywhere in your project. As long as they are
named with the .vwml extension and are embedded, the GameController will automatically
find them
- The name of any screen you create will be the name of the .vwml file (without extension)
by default unless overridden with the Name property in the file. Be careful not to
give .vwml files the same name.
- Add this code to your GameRunner class:
public VarmintWidget.EventHandledState GoOnTap(VarmintWidget tappedObject, Vector2 tapPosition)
{
// TODO: Add your button-handling code here
return VarmintWidget.EventHandledState.Handled;
}
- In the GameRunner constructor:
- Set up the GameController.OnLoaded event to call GameController.SetScreen("MainScreen", this)
- At this point, you should be able to run the program and see your first simple screen
==== STEP 3: Adding Content (Under construction)
Note: If you put a content folder in your share project, make sure this code is in
your .projitems file:
<ItemGroup>
<MonoGameContentReference Include="$(MSBuildThisFileDirectory)Content\Content.mgcb" />
</ItemGroup>