dir.by  
  Search  
Programming, development, testing
MonoGame - develop games on C# for computers (Windows, Linux), phones (Android, iOS), game consoles (Xbox, PlayStation, Nintendo Switch)
Create a new MonoGame application on the computer (Windows) in emulator mode Android
  Looked at 7867 times    
 Create a new MonoGame application on the computer (Windows) in emulator mode Android 
last updated: 16 Augusta 2023
In order to learn how to write games in MonoGame , you need to create a new MonoGame application.
Step 1. Open Visual Studio
To write a game using MonoGame and for the game to work on different platforms, you need Visual Studio with the Xamarin option.

If you do not have Visual Studio installed with the Xamarin option, you need install Visual Studio with Xamarin option ...
Open Visual Studio 2022
or
Open Visual Studio 2019
 
Attention!
If you do not have the MonoGame library installed, you need to install: Installing MonoGame (download and install) for Windows inside Visual Studio ...
Step 2. Select "New Project"
Click on the menu: File → New → Project
Create a new MonoGame application on the computer  Windows  in emulator mode Android
Create a new MonoGame application on the computer (Windows) in emulator mode Android
Create a new MonoGame application on the computer  Windows  in emulator mode Android
Create a new MonoGame application on the computer (Windows) in emulator mode Android
 
I write the name of the project MyMonoGame
Create a new MonoGame application on the computer  Windows  in emulator mode Android
Create a new MonoGame application on the computer (Windows) in emulator mode Android
 
A new project has been successfully created:
A new MonoGame application has been created on computer  Windows  in emulator mode Android
A new MonoGame application has been created on computer (Windows) in emulator mode Android
Step 3. Let's look at the main file Game1.cs
  C#     File Game1.cs
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace MyMonoGame
{
     public class Game1 : Game
     {
          private GraphicsDeviceManager _graphics;
          private SpriteBatch _spriteBatch;

          public Game1()
          {
               _graphics = new GraphicsDeviceManager(this);
               Content.RootDirectory = "Content";
               IsMouseVisible = true;
          }

          protected override void Initialize()
          {
               // TODO: Add your initialization logic here

               base.Initialize();
          }

          protected override void LoadContent()
          {
               _spriteBatch = new SpriteBatch(GraphicsDevice);

               // TODO: use this.Content to load your game content here
          }

          protected override void Update(GameTime gameTime)
          {
               if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                    Exit();

               // TODO: Add your update logic here

               base.Update(gameTime);
          }

          protected override void Draw(GameTime gameTime)
          {
               GraphicsDevice.Clear(Color.CornflowerBlue);

               // TODO: Add your drawing code here

               base.Draw(gameTime);
          }
     }
}
 
In the Draw method, the entire screen is painted blue. Just like that:
GraphicsDevice.Clear(Color.CornflowerBlue);
 
Step 4. Compile the project
Compile the application: Menu → Build → Build Solution
No mistakes

Attention! There may be errors with an inappropriate Android version.
Answer: To fix these errors, you need to install a new Android platform.
Read more:Installing the platform Android (SDK 7.1.1 API 25) in Visual Studio ...
 
Step 5. Launching the project
Read more:Running and debugging the MonoGame application in emulator mode Andriod ...

Run the application by clicking on the green triangle and we will see the phone emulator in 1 minute:
Run a new MonoGame application on the computer  Windows  in emulator mode Android
Run a new MonoGame application on the computer (Windows) in emulator mode Android
 
← Previous topic
Installing MonoGame (download and install) for Windows inside Visual Studio
 
Next topic →
Запуск и отладка MonoGame приложения на компьютере(Windows) в режиме эмулятора Android
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
MonoGame
What is MonoGame?
Что такое Mono (виртуальная машина для C# в Unix) ?
What are the advantages of Monogame?
How to write a game in MonoGame and compile to different platforms: Windows computer, macOS computer, Android phone, iOS apple phone, Nintendo Switch game console
Download and install MonoGame
Download and install Microsoft Visual Studio to write MonoGame games on a computer with the Windows system
Open Visual Studio (to write a game using MonoGame)
Installing MonoGame (download and install) for Windows inside Visual Studio
Создаем и запускаем MonoGame приложение на компьютере (Windows) в режиме эмулятора Android
Create a new MonoGame application on the computer (Windows) in emulator mode Android
Запуск и отладка MonoGame приложения на компьютере(Windows) в режиме эмулятора Android
Запускается старая версия MonoGame приложения в debug в режиме эмулятора Android
Запуск и отладка MonoGame приложения на телефоне через USB
Запуск MonoGame приложения на Android телефоне (создание apk файла)
Android (устанавливаем)
Инсталлирование платформы Android (SDK 7.1.1 API 25) в Visual Studio ...
Create a Android virtual device in Visual Studio
Установка, запуск MonoGame приложения на компьютере с системой MacOSX
Installing, running MonoGame application on a computer with the operating system iOS (MacOSX) using Xamarin Studio
Installing, running MonoGame application on a computer with the operating system iOS (MacOSX) using Visual Studio
Функциональность MonoGame
Рисуем прямоугольник в новом MonoGame приложении
Добавляем файл png и рисуем картинку в новом MonoGame приложении
Рисуем текст в новом MonoGame приложении
Книги
Книги для изучения MonoGame

  Ваши вопросы присылайте по почте: info@dir.by  
Яндекс.Метрика