Contents tagged with MonoGame

  • Putting iAds in a MonoGame game

    Here is the code you need to add to Main.cs in you game to get iAds working. You don't need to add any unique IDs. The iAd SDK is able to work out what you app is by magic. Everything will work fine as long as your app is registered for iAds in iTunes Connect.

    I call the method SetupAdvert at the end of FinishedLaunching in Main.cs:

    private object _adBannerView;

    private bool _advertPausedGame;

    private void SetupAdvert()

    {

    int width, height;

    var view = (game.Services.GetService(

    typeof(UIViewController)) as UIViewController).View;

    if (view.Bounds.Width <= 320)

    { … more

  • Text effects in MonoGame and XNA

    In MonoGame you can load a SpriteFont in an XNB file created using the XNA Content Pipeline. You can then write text using SpriteBatch.DrawString. If you want to add effects to your text, there is no way to do this using just the DrawString method. There is a way however to create a SpriteFont that has effects built into this.

    There are two ways of building a font using the XNA Content Pipeline. The first way is using a Sprite Font Description. This uses an XML file and is an easy to compile a Sprite Font from a font on you computer. This is easy to make changes to, but it won't help us … more

  • Sharing your view model between Monogame and Xaml

    If you create a new Monogame Windows Store XAML Project. You will get a XAML page called GamePage.xaml and you'll get the monogame game class Game1.cs. If you want display data from your game class in XAML or if you want to take input from XAML into your game then these two sides are going to need to communicate.

    One way they can communicate is by sharing a view model. As the XAML page creates the instance of your game class, it can also let your game class know about it's view model. Like this in GamePage.xaml.cs:

    public GamePage(string launchArguments)

    {

    this.InitializeComponent();

    // … more

  • 1