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

Author Topic: problem with SFML blueprints "no match for call"  (Read 3925 times)

0 Members and 1 Guest are viewing this topic.

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
problem with SFML blueprints "no match for call"
« on: February 13, 2018, 12:10:56 pm »
i just bought the "SFML blueprints" i was following the book when i found this "error" in the code and i dont know understand why ( see the picture ) some can help me?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: problem with SFML blueprints "no match for call"
« Reply #1 on: February 13, 2018, 12:19:01 pm »
CircleShape takes a float as constructor parameter (see the docs).

However C++ should allow implicit conversion from int to float, so I'm not sure why it would error there.

The fix would probably be to use player(150.f). If that doesn't work, then there's a different issue and you'd need to show more code.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
Re: problem with SFML blueprints "no match for call"
« Reply #2 on: February 13, 2018, 12:49:32 pm »
yeah man, it still not working ( see first pic)
i try to change that line with other definition and it give me the same errore

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: problem with SFML blueprints "no match for call"
« Reply #3 on: February 13, 2018, 01:05:59 pm »
Well you didn't just change what I suggested, but you changed more.

The player initialization can't be part of the window constructor (closing bracket before the player).
You can't call a function in the initialization list, but you have to use the constructor.
And the initialization list can't have a semicolon at the end.

Game::Game()
: window(sf::VideoMode(800, 600), "02_Game_Archi")
, player(150.f)
{
    player.setFillColor(sf::Color::Blue);
    player.Position(10.f, 20.f);
}

As you can see in my code, I also recommend to not use using namespace sf; and instead just specifying it. Makes it a lot easier to read the code and see what is an SFML type and what isn't.

(Also I don' think you want a width of 8000 ;) )
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
Re: problem with SFML blueprints "no match for call"
« Reply #4 on: February 13, 2018, 08:10:27 pm »
I'm sorry to bother you ... i think i fix the problem but  the window dont want to stay open!

#include "Game.h"

void Game::run() {
        while (window.isOpen()){  //>>>>>>>>>> never get inside this
                processEvents();
                update();
                render();
        }
}
Game::Game() {
        sf::RenderWindow window(sf::VideoMode(800, 600), "Fast-Typing: The Game",sf::Style::Titlebar);
        sf::CircleShape player(150);
        player.setFillColor(sf::Color::Blue);
        player.setPosition(10, 20);
} ///// the window close after this

Game::~Game() {}
void Game::processEvents() {

        while (window.isOpen()) { // main Loop
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed) {
                                window.close();
                        }
                }
        }
}
void Game::update() {
}
void Game::render() {
        window.clear(sf::Color::Black);
        window.draw(player);
        window.display();
}
 


class Game {

public:
        Game();
        void run();
        virtual ~Game();

public:
        void processEvents();
        void update();
        void render();

        sf::RenderWindow window;
        sf::CircleShape player;
};

 



#include <iostream>
#include "Game.h"
using namespace std;

int main() {

        Game myGame;
        myGame.run();

        return 0;
}


 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: problem with SFML blueprints &quot;no match for call&quot;
« Reply #5 on: February 13, 2018, 09:55:05 pm »
You're now just creating a local variable with the game constructor. Once the constructor ends the local window variable gets destroyed again.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything