Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to draw a rectangle in monogame

 Texture2D rect = new Texture2D(graphics.GraphicsDevice, 80, 30);

 Color[] data = new Color[80*30];
 for(int i=0; i < data.Length; i++) data[i] = Color.Chocolate;
 rect.SetData(data);

 Vector2 coor = new Vector2(10, 20);
 spriteBatch.Draw(rect, coor, Color.White);
Comment

draw rectangle monogame full code

# In The Public Class
Texture2D whiteRectangle;
# In LoadContent Funtion
whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
whiteRectangle.SetData(new[] { Color.White });
# In Draw Funtion
_spriteBatch.Begin();
_spriteBatch.Draw(whiteRectangle, new Rectangle(0, 0, 30, 30),Color.Chocolate);
_spriteBatch.End();
Comment

PREVIOUS NEXT
Code Example
Csharp :: net.core "a path base can only be configured using iapplicationbuilder.usepathbase()" 
Csharp :: c# thread wait 
Csharp :: c# filter non alphanumeric characters 
Csharp :: remove session in dotnet core 
Csharp :: c# add guid to array 
Csharp :: string format comma c# 
Csharp :: c#image to bytes 
Csharp :: remove character from string c# 
Csharp :: c# array remove first element 
Csharp :: string from byte array c# 
Csharp :: convert int to string in linq query c# 
Csharp :: checkbox value unchecked after return view model 
Csharp :: c# dynamic object get value 
Csharp :: wpf yes no message box exit 
Csharp :: unity mouse movement 
Csharp :: newtonsoft json conditionally ignore property 
Csharp :: c# read char 
Csharp :: js invoke async function blazor 
Csharp :: C# How to change the text colour? 
Csharp :: c sharp array to list 
Csharp :: c# getforegroundwindow 
Csharp :: string in int c# 
Csharp :: how to pause physics in unity c# 
Csharp :: merge point of two list 
Csharp :: unity waituntil coroutine 
Csharp :: how to spawn a object in unity 
Csharp :: c# hello world 
Csharp :: how to loop an animation in unity 
Csharp :: maximize window c# console 
Csharp :: base64 decode how used in c# 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =