Skip to content

73D38A77

Marcel Härtel edited this page Aug 27, 2023 · 2 revisions

MonoGameService Class

This class inherits from EditorService, which provides basic functionality of the MonoGame.Framework. The [!:MonoGame.Forms.Controls.MonoGameControl] inherits from this class.

Remarks

Note: this class provides a game loop. The InvalidationService is not using a game loop.

Definition

Namespace: MonoGame.Forms.NET.Services
Assembly: MonoGame.Forms.NET (in MonoGame.Forms.NET.dll) Version: 3.2.0

C#

public sealed class MonoGameService : EditorService
Inheritance ObjectEditorService → MonoGameService

Properties

BackgroundColor The color used to clear the screen / control with Clear(Color)
(Inherited from EditorService)
Camera The Camera2D component.
(Inherited from EditorService)
Content The ContentManager is for loading custom content from the content root.
(Inherited from EditorService)
Font A built-in font, which is used by the integrated display. You can also use it as debugging font for example.
(Inherited from EditorService)
FontHeight Height of the display Font - Cached in InitializeService().
(Inherited from EditorService)
FPSCounter The FPSCounter component.
(Inherited from EditorService)
GameTime Get the current GameTime of the game loop.
GetAbsoluteMousePosition Get the current mouse position.
(Inherited from EditorService)
GetCurrentMultiSampleCount Get the current active MultiSampleCount.
(Inherited from EditorService)
GetRelativeMousePosition Get the current mouse position in the control.
(Inherited from EditorService)
GetRenderTargetManager Get the internal EditorService.RenderTargetManager.

Remarks

When working with custom RenderTarget2D's, it's strongly recomended to create these render targets with this RenderTargetManager, because they will updated automatically when the client size or the multi sample count changes.
(Inherited from EditorService)

GraphicsDevice The GraphicsDevice.
(Inherited from EditorService)
Pixel A plain white pixel mainly to draw the background of the integrated display, but you can also use it in your custom control.
(Inherited from EditorService)
ResourceContent The ResourceContentManager is for loading custom content from a resource file.
(Inherited from EditorService)
spriteBatch The SpriteBatch.
(Inherited from EditorService)
SwapChainRenderTarget A swap chain used for rendering to a secondary GameWindow. Note: When working with different RenderTarget2D, you need to set the current render target back to the SwapChainRenderTarget as this is the real 'Back Buffer'. 'GraphicsDevice.SetRenderTarget(null)' will NOT work as you are doing usally in MonoGame. Instead use 'GraphicsDevice.SetRenderTarget(SwapChainRenderTarget)'. Otherwise you will see only a black control window.
(Inherited from EditorService)

Methods

AddDefaultComponents Add all default (integrated) GameComponent's to the GameComponentCollection. These are basically a ICamera2D and a FPSCounter components.

Remarks

If you want to add your own ones, call Components.Add(); from your custom MonoGame.Forms.Control.
(Inherited from EditorService)

BeginAntialising Everything between BeginAntialising() and EndAntialising() will be affected by MSAA.
(Inherited from EditorService)
BeginCamera2D Use 'BeginCamera2D' as a replacement of SpriteBatch.Begin(SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix?).

Remarks

Automatically uses the Matrix of the Camera2D component!
(Inherited from EditorService)

BeginRenderTarget Everything between BeginRenderTarget() and EndRenderTarget() will be drawn to the RenderTarget2D.
(Inherited from EditorService)
CamMove Move the camera by the value defined in the parameter amount.
(Inherited from EditorService)
CamRotate Rotate the camera component.
(Inherited from EditorService)
CamZoom Zoom the camera component.
(Inherited from EditorService)
DisableRenderTargets Disable all custom RenderTarget2D's hold by the EditorService.RenderTargetManager, before they becoming reactivated after 500 milliseconds.
(Inherited from EditorService)
Dispose Disposes the contents of this service.
(Inherited from EditorService)
EndAntialising Everything between BeginAntialising() and EndAntialising() will be affected by MSAA.
(Inherited from EditorService)
EndCamera2D Use this to end the SpriteBatch, previously opened by BeginCamera2D(SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect).
(Inherited from EditorService)
EndRenderTarget Everything between BeginRenderTarget() and EndRenderTarget() will be drawn to the RenderTarget2D.
(Inherited from EditorService)
GetCamRotation Get the current camera rotation.
(Inherited from EditorService)
GetCamZoom Get the current camera zoom.
(Inherited from EditorService)
RemoveAllComponents Remove all GameComponent from the GameComponentCollection. This also counts for your own ones!

Remarks

If you only want to remove your own ones, call Components.Remove(); from your custom MonoGame.Forms.Control.
(Inherited from EditorService)

RemoveDefaultComponents Remove all default (integrated) GameComponent's from the GameComponentCollection. These are basically a ICamera2D and a FPSCounter components.

Remarks

If you want to add your own ones, call Components.Add(); from your custom MonoGame.Forms.Control.
(Inherited from EditorService)

ResetCam Resets all or specific values from the camera component to their defaults.
(Inherited from EditorService)
ResourceContentManagerInitialize Initializes a custom ResourceContentManager.
(Inherited from EditorService)

Events

RenderTargetsRefreshed Subscribe to this event in your custom control to get notified when RenderTarget2D's, hold by the EditorService.RenderTargetManager, got refreshed.
(Inherited from EditorService)

See Also

Reference

MonoGame.Forms.NET.Services Namespace

Clone this wiki locally