• Advertisement
Sign in to follow this  

Sfml 1.6 Modules Operator Error

This topic is 1894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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. Edited by JTippetts

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement