SFML community forums

Help => Graphics => Topic started by: ansh93 on November 10, 2014, 02:55:10 am

Title: sf::Transform.Translate not moving the object
Post by: ansh93 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
Title: Re: sf::Transform.Translate not moving the object
Post by: Gambit 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
Title: Re: sf::Transform.Translate not moving the object
Post by: ansh93 on November 10, 2014, 06:59:39 am
position matrix is sf::Transform, I guess that explains everything !!
Title: Re: sf::Transform.Translate not moving the object
Post by: Laurent 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.