Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How do I set a position/scale etc on a single axis?  (Read 3038 times)

0 Members and 1 Guest are viewing this topic.

Ignatius_Z

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
How do I set a position/scale etc on a single axis?
« 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.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: How do I set a position/scale etc on a single axis?
« Reply #1 on: February 06, 2021, 03:34:10 am »
Perfectly fine

Ignatius_Z

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: How do I set a position/scale etc on a single axis?
« Reply #2 on: February 06, 2021, 03:44:11 am »
are you sure there isn't a way of just changing one part of the vector?

Ignatius_Z

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: How do I set a position/scale etc on a single axis?
« Reply #3 on: February 10, 2021, 04:35:44 am »
bump?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How do I set a position/scale etc on a single axis?
« Reply #4 on: February 10, 2021, 08:32:20 am »
If there was a way, it would be in the documentation ;)
Laurent Gomila - SFML developer

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: How do I set a position/scale etc on a single axis?
« Reply #5 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.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything