This is the exception I'm getting:
A first chance exception of type 'System.NullReferenceException' occurred in Bile.exe
Additional information: Object reference not set to an instance of an object.
Code:
Cerc ceva = GenerateNewParticle();
cercuri.Add(ceva);
The error is in second line, and i don't know why, because my function shouldn't return null
public Cerc GenerateNewParticle()
{
Vector2 position = Location;
Random random = new Random();
Color color = new Color(
(float)random.NextDouble(),
(float)random.NextDouble(),
(float)random.NextDouble());
return new Cerc(Texture, position, color);
}
This is from Cerc class
public class Cerc
{
public Texture2D Texture;
public Color Color;
float x = 0, y = 0;
float varx = 2, vary = 2;
public Cerc(Texture2D texture,Vector2 location,Color color)
{
x = location.X + 50;
y = location.Y + 50;
Texture = texture;
Color = color;
}