Jump to content

  • Log In with Google      Sign In   
  • Create Account

Sfml 1.6 Modules Operator Error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Cryusaki   Members   -  Reputation: 471

Like
0Likes
Like

Posted 12 November 2012 - 07:27 PM

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!

Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8652

Like
0Likes
Like

Posted 12 November 2012 - 07:45 PM

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, 12 November 2012 - 07:46 PM.


#3 Cryusaki   Members   -  Reputation: 471

Like
0Likes
Like

Posted 12 November 2012 - 08:52 PM

Thank you, I typecasted it into an integer and it worked great c:




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS