Sfml 1.6 Modules Operator Error

Started by
1 comment, last by Cryusaki 11 years, 5 months ago
I am trying to use the modules operator on the coordinates of my sprite (Spritex = Sprite.GetPosition().X % 16) and I am getting an error

Error: invalid operands of types 'const float' and 'int' to binary 'operator%'

I am on CodeBlocks and it doesnt matter what variable Spritex is, always getting an error

Help!
Advertisement
sf::Vector2f (returned by GetPosition()) is a vector of float types, 16 is an integer type. % wants them both to be integers. You can explicitly cast Sprite.GetPosition().X to int and it should work.
Thank you, I typecasted it into an integer and it worked great c:

This topic is closed to new replies.

Advertisement