SFML community forums

Help => General => Topic started by: magyarosipeter on July 08, 2018, 09:53:01 pm

Title: setSize error with structure.
Post by: magyarosipeter on July 08, 2018, 09:53:01 pm
struct Bat {
    sf::RectangleShape shape();
    int x=360;
    int vx=1;
} batleft, batright;

int main ()
{
     (...)
     batleft.shape.setSize(sf::Vector2f(50, 20))
     batright.shape.setSize(sf::Vector2f(50, 20))
     (...)
}
 

Hey everyone. This code gives me the following error : 'batleft.Bat::shape' does not have class type. Same with the right one. I tried setting the size in the declaration but it gives me even more errors ( expected ')' before numeric constant / expected ';' at end of member decalaration / expected unqualified-id before numeric constant ).
Title: Re: setSize error with structure.
Post by: G. on July 09, 2018, 05:38:00 am
Quote
struct Bat {
    sf::RectangleShape shape();
You're declaring a function named shape, returning an sf::RectangleShape.
Remove the parentheses to declare a data member named shape of type sf::RectangleShape.
Title: Re: setSize error with structure.
Post by: magyarosipeter on July 09, 2018, 11:36:02 am
Right... bad mistake. Thanks   :D