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

Author Topic: Make some sfml objects as static  (Read 2058 times)

0 Members and 1 Guest are viewing this topic.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Make some sfml objects as static
« on: November 28, 2010, 02:31:36 pm »
Hi,

I want make some objects static like RenderWindow,

Instaed of make on main file:
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics")

I have a classe called GameObjects, that will have a static attribute to hold the RenderWindow.

But i dont know how to do it, i get some erros, because i dont know how to do it without pointer objects, like:

GameObjects::app = new Object...

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Make some sfml objects as static
« Reply #1 on: December 01, 2010, 12:31:38 am »
Always post error messages, "i get some erros" is not very helpful.
I'm assuming you're getting linker errors.
I think you want something like this:
Code: [Select]

//GameObjects.hpp
class GameObjects
{

private:
  static sf::RenderWindow myApp;
};
//GameObjects.cpp
sf::RenderWindow GameObjects::myApp(sf::VideoMode(800, 600, 32), "SFML Graphics");