Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Sfml 1.6 Modules Operator Error

4: Adsense

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   

510
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!

#2 JTippetts   Moderators   

12636
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   

510
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.