What is the difference in computer/memory usage in the following code examples, also if there is any benefit to one or an other. Rough class below:
class Player
{
private Rectangle boxRectangle = new Rectangle(*defined elsewhere*);
private Vector2 boxPosition = new Vector2;
//box rectangle is moved constantly (through keyboard input)
public void Update()
{
//example one
boxPosition.X = boxRectangle.X;
boxPosition.Y = boxRectangle.Y;
//example two
boxPosition = new Vector2(boxRectangle.X, boxRectangle.Y);
}
}
Which is more efficient to use when updating the Vector2?
Aucun commentaire:
Enregistrer un commentaire