Can't modify XNA Vector components

前端 未结 4 1083
花落未央
花落未央 2020-12-20 16:57

I have a class called Sprite, and ballSprite is an instance of that class. Sprite has a Vector2 property called Position.

I\'m trying to increment the Vector\'s X c

4条回答
  •  难免孤独
    2020-12-20 17:15

    An easy alternative is this:

    instead of: sprite.Position.X = 10;

    use: sprite.Position = new Vector2(10, sprite.Position.Y);

    instead of: sprite.Position.Y = 10;

    use: sprite.Position = new Vector2(sprite.Position.X, 10);

    instead of: sprite.Position.X += 10;

    use: sprite.Position += new Vector2(0, 10);

    instead of: sprite.Position.Y += 10;

    use: sprite.Position += new Vector2(10, 0);

提交回复
热议问题