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

Author Topic: [SFML 1.6] Functions don't exist in sf::Window?  (Read 2287 times)

0 Members and 1 Guest are viewing this topic.

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
[SFML 1.6] Functions don't exist in sf::Window?
« on: March 26, 2013, 12:34:30 am »
So, I'm kind-of new to SFML, and have been using it for a few days. I got the examples working, so I know libraries work. I'm on Debian 6.0 (Sqeeze). I'm working on the event's section of the SFML, and it keeps saying it does not exist (the functions).

This is my header file.
#ifndef _APP_H_
#define _APP_H_

#include <SFML/System.hpp>
#include <SFML/Window.hpp>

class App{
        private: // Here is the Game Stuff
                sf::Window gameScreen;
        public: // Game Starting Methods
                App();
                int Execute();
                // Game Loop Methods
                bool Init();
                void Event();
                void Loop();
                void Render();
                void Cleanup();
};

#endif

And this is the main problem file:
#include "app.h"

App::App(){
        // Set up basic game stuff.
        gameScreen.Create(sf::VideoMode(800, 600), "Lazeroids!");
}

int App::Execute(){
        if (Init() == false)
                return -1;
        sf::Event event;
        while(gameScreen.isOpen()){
                while(gameScreen.pollEvent(event)){
                        Event();
                }
                Loop();
                Render();
        }
        Cleanup();
        return 0;
}

int main(int argc, char *argv[]){
        // Create the actual game object.
        // Only 3 lines here.
        // Oh, and don't forgot to call the game to run.
        App game;
        return game.Execute();
}

The problem is in the section of code that has these lines:
while(gameScreen.isOpen()){
                while(gameScreen.pollEvent(event)){
                        Event();
                }

The error comes up saying:
app.cpp: In member function ‘int App::Execute()’:
app.cpp:12: error: ‘class sf::Window’ has no member named ‘isOpen’
app.cpp:13: error: ‘class sf::Window’ has no member named ‘pollEvent’

I've tried a few different function capitalization ways, and even included <SFML/Event.hpp> (Which doesn't seem to exist?)

What am I doing wrong.

P.S. How would I have a function that accepts an event? (Like in the arguments)

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: [SFML 1.6] Functions don't exist in sf::Window?
« Reply #1 on: March 26, 2013, 01:01:19 am »
You're using SFML 2 code  with SFML 1.6 libraries. Try gameScreen.IsOpened() and gamescreen.GetEvent(Event) instead and it should work. Or you could switch to SFML 2 and not have to change your code.  :P
DSFML - SFML for the D Programming Language.

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [SFML 1.6] Functions don't exist in sf::Window?
« Reply #2 on: March 26, 2013, 01:18:31 am »
Oh, okay. That did the trick, although can you answer my question, is there any way I can pass an event via a function? So my Event function can handle them? I tried getting it via

int Event(sf::Event*){...}
although that doesn't seem to work.
« Last Edit: March 26, 2013, 01:25:18 am by Link »

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: [SFML 1.6] Functions don't exist in sf::Window?
« Reply #3 on: March 26, 2013, 05:28:26 am »
What about it isn't working?

Passing an event into your own function shouldn't be an issue. Maybe you're using it wrong? You should post some code!
DSFML - SFML for the D Programming Language.

Link

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [SFML 1.6] Functions don't exist in sf::Window?
« Reply #4 on: March 26, 2013, 05:38:08 pm »
Kinda what I'm asking, how do I pass it, I have no idea? the code I posted last message doesn't work. what is the proper way?

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: [SFML 1.6] Functions don't exist in sf::Window?
« Reply #5 on: March 27, 2013, 08:15:35 am »
I mean, you could pass it how ever you want. For example..

void doStuffWithMyEvent(sf::Event event)
{
     switch(event.type)
     {
          //do stuff here
      }
}
 

Just do what you normally do with your event. The only difference is you have it encapsulated in a function, right?
DSFML - SFML for the D Programming Language.

 

anything