Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error: ‘sf::FloatRect’ has no member named ‘getPosition’  (Read 3152 times)

0 Members and 1 Guest are viewing this topic.

MickeyKnox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
From this code

sprite.getGlobalBounds().getPosition()

I get this error:

error: ‘sf::FloatRect’ {aka ‘class sf::Rect<float>’} has no member named ‘getPosition’
   26 |         info.setPosition(image->sprite.getGlobalBounds().getPosition());
      |                                                          ^~~~~~~~~~~


Accoding to the documentation Rect does have a member getPosition: https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1Rect.php

What am I missing?

MickeyKnox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: error: ‘sf::FloatRect’ has no member named ‘getPosition’
« Reply #1 on: August 25, 2024, 10:37:01 pm »
Ups my bad. I just realized that I'm still on SFML 2.5.1. Accoding to the changelog, the missing function was introduced in 2.6

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: error: ‘sf::FloatRect’ has no member named ‘getPosition’
« Reply #2 on: August 25, 2024, 11:11:10 pm »
Yep, it's been added in 2.6.

I highly recommend to update SFML ;)

As a side note for SFML 3 users, the functions were replaced in favor of data members position and size.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/