Advertisement

Sfml 1.6 Modules Operator Error

Started by November 13, 2012 01:27 AM
1 comment, last by Cryusaki 12 years 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!
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.
Advertisement
Thank you, I typecasted it into an integer and it worked great c:

This topic is closed to new replies.

Advertisement