dir.by  
  Поиск  
Компьютер, программы
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 
посмотрели 9522 раз
обновлено: 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 →
Running and debugging the MonoGame app on your computer (Windows) in Android emulator mode
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
MonoGame
What is MonoGame?
What is Mono (Virtual Machine for C# on 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
Create and run a MonoGame application on a computer (Windows) in Android emulator mode
Create a new MonoGame application on the computer (Windows) in emulator mode Android
Running and debugging the MonoGame app on your computer (Windows) in Android emulator mode
Runs the old version of the MonoGame app in debug in Android emulator mode
Running and debugging the MonoGame application on your phone via USB
Running the MonoGame application on an Android phone (creating an apk file)
Android (install)
Installing the Android Platform (SDK 7.1.1 API 25) in Visual Studio ...
Create a Android virtual device in Visual Studio
Installing, running the MonoGame application on a computer with the MacOSX system
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 Functionality
How to Draw a Rectangle in the New MonoGame App
Add a png file and draw a picture in the new MonoGame application
How to draw text in the new MonoGame app
Books
Books to learn MonoGame

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