SFML community forums

Help => Graphics => Topic started by: Ignatius_Z on February 06, 2021, 01:07:10 am

Title: How do I set a position/scale etc on a single axis?
Post by: Ignatius_Z on February 06, 2021, 01:07:10 am
For example how do I use
sprite.setPosition(x, y);
but only for x OR y instead of both?

I used
sprite.setPosition(20, sprite.getPosition().y);
but i'd imagine thats not the most efficient way of doing it. Apologies again for the very noob question and its probably right in front of me but thanks in advanced.
Title: Re: How do I set a position/scale etc on a single axis?
Post by: G. on February 06, 2021, 03:34:10 am
Perfectly fine
Title: Re: How do I set a position/scale etc on a single axis?
Post by: Ignatius_Z on February 06, 2021, 03:44:11 am
are you sure there isn't a way of just changing one part of the vector?
Title: Re: How do I set a position/scale etc on a single axis?
Post by: Ignatius_Z on February 10, 2021, 04:35:44 am
bump?
Title: Re: How do I set a position/scale etc on a single axis?
Post by: Laurent on February 10, 2021, 08:32:20 am
If there was a way, it would be in the documentation ;)
Title: Re: How do I set a position/scale etc on a single axis?
Post by: Stauricus on February 10, 2021, 11:58:27 am
you can change parts of a vector, but the vector inside the sf::Sprite class has restricted access and there is no setter method for only parts of it.

so you can change the source code to include these methods (overkill) OR you can do the way you did, which isn't inefficient at all.