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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Cakemix

Pages: [1]
Window / [SOLVED] RenderWindow disappears immediately
« on: May 07, 2009, 08:57:08 pm »
Hey there. I hope a problem like mine really wasn't already here... ;) (I tried to find it with the search-thing here)

Now: I'm trying to make a little game with SFML. The problem I have here is that my own class, which is a "child" (or derived?) of the sf::RenderWindow class, causes a problem.
So this class (which is called "MenuInterface") has all the stuff which RenderWindow has and additionally some Attributes and Operations, e.g. Sprites and Images, which are usefull in the MainMenu of my game.

Everything compiles etc., but then the window appears for a very short time (less than sec.. just flashes) and disappears.
I don't have any idea why this is happenning and I hope someone out there is able to help me. (since I'm not that experienced with SFML, the mistake may lay somewhere, I would never expect it...)

Here are some parts of my code:

Class definition:
Code: [Select]
#include "Point.h"
#include "SFML/Graphics.hpp"
class Interface;
* Is the window for the main menu. As well loads images and displays
* the sprites needed in the main menu.

class MenuInterface: public sf::RenderWindow
        sf::Image *imgMenu[3];
        sf::Sprite *sprMenu[3];
        int maxSprMenuID;
        sf::Event myEvent; //needed to respond on the user's actions
        Interface *myInterface; //needed to change the Interface's mode
        Point mousePos;
        void initImages(); //loads all picture needed for the menu
        void initSprites(); //sets the position etc. of the sprites
        bool mouseOverSprite(int pSprMenuID);

        MenuInterface(Interface *pInterface);
        float tick(); //does everything which is needed and returns frameTime

And the implementation of the function "tick", which can be seen as the main-function.
This function gets called by another class in a while-loop, untill the program exits.
The lines:
Code: [Select]
   std::cout << "Frame gezeichnet." << std::endl;
    std::cout << GetFrameTime() << std::endl;

are used for debugging and my debug-console is spammed with those couts all the time. So even then, when the window seems to have dissappeared.
Now the whole code of tick!
Code: [Select]
float MenuInterface::tick()
    case sf::Event::Closed: //On window closed:
        Close(); //close it
       // myInterface->setMode(-1); //set new mode

    case sf::Event::MouseMoved:
        mousePos.x = myEvent.MouseMove.X; //Set new mousePos
        mousePos.y = myEvent.MouseMove.Y;

    case sf::Event::MouseButtonReleased:

        //Maus ├╝ber dem Button Start?

    //clear and redraw everything:
    for(int i = 0; i <= maxSprMenuID; i++)


    std::cout << "Frame gezeichnet." << std::endl;
    std::cout << GetFrameTime() << std::endl;

    return GetFrameTime();

Pages: [1]