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

Author Topic: expected primary expression when using a pointer  (Read 1301 times)

0 Members and 1 Guest are viewing this topic.

yasser

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
expected primary expression when using a pointer
« 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);
}

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: expected primary expression when using a pointer
« Reply #1 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);
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

yasser

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: expected primary expression when using a pointer
« Reply #2 on: July 01, 2019, 01:24:21 pm »
that fixed it, thanks