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

Author Topic: sf::Transform.Translate not moving the object  (Read 1663 times)

0 Members and 1 Guest are viewing this topic.

ansh93

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::Transform.Translate not moving the object
« on: November 10, 2014, 02:55:10 am »
I have created my own function for translate as

void Transform::Translate(sf::Vector2f deltaPosition)
        {
                Position.x+=deltaPosition.x;
                Position.y+=deltaPosition.y;
                positionMatrix.translate(deltaPosition);
        }

but it doesnt work at time
From my physics class if I call this as
gravity = sf::vector2f(10,0)
transform->Translate(gravity)
it works
but if I call it as
position = gravity/mass*dt*dt;
transform->Translate(position);
it doesnt works
Any idea where I might be wrong ?
I have checked the values for delta position and I am getting proper values in there
but still the object is not moving

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: sf::Transform.Translate not moving the object
« Reply #1 on: November 10, 2014, 04:28:08 am »
what is positionMatrix? Also what are you trying to do? What is the purpose of translate? Is it supposed to modify deltaPosition or something? Please look at this: http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368

ansh93

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: sf::Transform.Translate not moving the object
« Reply #2 on: November 10, 2014, 06:59:39 am »
position matrix is sf::Transform, I guess that explains everything !!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Transform.Translate not moving the object
« Reply #3 on: November 10, 2014, 08:47:19 am »
It works with certain values, so you know that the code you're showing is ok. But the problem can be anywhere else, so unless you show us a complete and minimal code that reproduces the problem, there's nothing we can do.

You can also try to watch the content of the sf::Transform with your debugger: the translation should be added to the first two elements of the 4th column of the matrix.
Laurent Gomila - SFML developer