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

Author Topic: onCreate() text glitch  (Read 2481 times)

0 Members and 1 Guest are viewing this topic.

StDH

  • Jr. Member
  • **
  • Posts: 56
  • {⛺.⛺}
    • View Profile
    • Worst ever ^^
onCreate() text glitch
« on: May 11, 2014, 12:27:13 pm »
language: c++
visual studio ultimate 2013
sfml 2.1 static [20.02.2014]

minimal code:
namespace game
{
        class Window : public sf::RenderWindow
        {
                public:
                        void onCreate();
        };
};

void game::Window::onCreate()
{
        // load files
}

first time it appears when i tried loading files inside onCreate(),
so i removed line that load files in onCreate() but it was still
appearing .... then i removed whole function onCreate() and
glitch disappeared.
I tried this more time to be sure it isn't my fault
« Last Edit: May 11, 2014, 12:41:25 pm by SDH »
<StDH> Imagine a girl writing you this: My farts smell good
<Slipxy> married.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: onCreate() text glitch
« Reply #1 on: May 11, 2014, 12:51:43 pm »
I have no idea what's the purpose of your onCreate() method, let alone how it relates to the font problem.

Please read this thread carefully and edit your post accordingly, so that we can help you in a meaningful way.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

StDH

  • Jr. Member
  • **
  • Posts: 56
  • {⛺.⛺}
    • View Profile
    • Worst ever ^^
Re: onCreate() text glitch
« Reply #2 on: May 11, 2014, 12:53:41 pm »
I have no idea what's the purpose of your onCreate() method, let alone how it relates to the font problem.

Please read this thread carefully and edit your post accordingly, so that we can help you in a meaningful way.

some search may help you:
http://www.sfml-dev.org/documentation/2.1/classsf_1_1Window.php#a106633b9be49b27f83d4712689b493eb
« Last Edit: May 11, 2014, 12:55:12 pm by SDH »
<StDH> Imagine a girl writing you this: My farts smell good
<Slipxy> married.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: onCreate() text glitch
« Reply #3 on: May 11, 2014, 12:57:45 pm »
I'm aware of this function, but I still don't know how you use it and how what problems you get exactly. And to be honest I doubt you really need inheritance here -- what does your custom window class do that cannot be achieved through composition?

Anyway, please come up with a minimal complete example as described in the thread I linked.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

StDH

  • Jr. Member
  • **
  • Posts: 56
  • {⛺.⛺}
    • View Profile
    • Worst ever ^^
Re: onCreate() text glitch
« Reply #4 on: May 11, 2014, 01:12:29 pm »
class Window : public sf::RenderWindow
{
        private:
                sf::Font font;
                sf::Text text;

        public:
                void onCreate()
                {
                        font.loadFromFile("assets/fnt/orbitron/medium.otf");

       
                        text.setFont(font);
                        text.setCharacterSize(14);
                        text.setColor(sf::Color::White);
                        text.setString("0123456789-\nabcdefghijklmo\npqrstuvwxyz");
                }

                void draw_()
                {
                        draw(text);
                }
};

void main()
{
        Window window;
        window.create(sf::VideoMode(800,600,32), "...");

        while (window.isOpen())
        {
                window.clear();
                window.draw_();
                window.display();
        }
}
<StDH> Imagine a girl writing you this: My farts smell good
<Slipxy> married.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: onCreate() text glitch
« Reply #5 on: May 11, 2014, 04:15:45 pm »
Don't expect sf::RenderWindow to work well if you don't call its onCreate function ;)

        void onCreate()
        {
            sf::RenderWindow::onCreate();
            ...
        }

This function is not really meant to be used publicly, you should really think about another design, not involving SFML internal stuff.
Laurent Gomila - SFML developer

StDH

  • Jr. Member
  • **
  • Posts: 56
  • {⛺.⛺}
    • View Profile
    • Worst ever ^^
Re: onCreate() text glitch
« Reply #6 on: May 11, 2014, 04:44:06 pm »
I was just curious, so i tested that function. :)
<StDH> Imagine a girl writing you this: My farts smell good
<Slipxy> married.