SFML community forums

Help => Graphics => Topic started by: yasser on July 01, 2019, 12:48:14 am

Title: expected primary expression when using a pointer
Post by: yasser on July 01, 2019, 12:48:14 am
i have a sprite and a pointer with the sprite's adress,but everytime i try to access the sprite to modify it i get
"expected primary expression  before ' . ' token"
here is my code:
Quote
*bmp_ptr = sf::Sprite.setRotation(); //error here
    bmp_gun.setPosition(sf::Vector2f(110.f,50.f));
    class_window.draw(bmp);
    class_window.draw(bmp_gun);

and here is the declaration:

Quote
vehicles::vehicles(sf::RenderWindow& window)
:class_window(window)
{
    sf::Sprite bmp;
    sf::Sprite bmp_gun;
    sf::Texture bmp_texture;
    sf::Texture bmp_gun_texture;
    bmp_ptr = &bmp;
    bmp_texture.loadFromFile("bmp.png");
    bmp_gun_texture.loadFromFile("bmp turret.png");
    bmp_gun.setTexture(bmp_gun_texture);
    bmp.setTexture(bmp_texture);
}
Title: Re: expected primary expression when using a pointer
Post by: Hapax on July 01, 2019, 01:14:25 am
*bmp_ptr = sf::Sprite.setRotation(); //error here
I think you want this to be:
(*bmp_ptr).setRotation(0.f);
or just:
bmp_ptr->setRotation(0.f);
Title: Re: expected primary expression when using a pointer
Post by: yasser on July 01, 2019, 01:24:21 pm
that fixed it, thanks