Hi,
I have some problems with {get; set;} thing, hope you could help.
So I have a class:
class Parts
{
public Vector2 partPos { get; set; }
public bool moving { get; set; }
/*public Parts()
{
}*/
//private Vector2 PartPos;
/*public Vector2 partPos
{
get
{
return PartPos;
}
set
{
PartPos = value;
}
}*/
//private bool Moving;
/*public bool moving
{
get
{
return Moving;
}
set
{
Moving = value;
}
}*/
}
Problem is that I can't modify only the X or only the Y coordinate of Vector2 partPos (I have to create a new Vector2 and then set it to partPos). Is there any way of doing that with get set properties? Because this part of code is not acceptable:
public float partPos.X {get; set;}
Also I have thought about adding this line of code:
public float partPosX { get { return partPos.X; } set { partPos.X = value; } }
, but it's also not acceptable because partPos is not a variable.
I think I don't get something here :/.
Thanks in advance for any help!