Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu::Window and C++ member constructors
- By Maverick Date 2009-06-08 19:18 Edited 2009-06-08 19:21
I'm trying to load window settings from a file. However, all the examples show the Gosu window's height and width and etc set in stone:

MyWindow ( ) : Gosu::Window ( 640, 480, false )

Like that in the constructor. I'm trying to have variables tell the window it's size. Any help?

I have changed the constructor to allow the variables to be "hopefully" modifiable to the window but I have the window as an object in a class so it can also handle room states.

class RoomStateController
{
//.... blah blah
public:

MyWindow window; //<- The compiler technically states this as MyWindow window ( ); therefore constructing it

// blah blee blah

RoomStateController ( int Width, int Height )
{
     window( Width, Height ); //illegal!
}

//...
//..

Hopefully you can see my dilemma and help. :]
- By jlnr (dev) Date 2009-06-08 19:33
You are so close. :)

In constructors, you construct your members via the initializer list (the part after the colon), just like you do with the base class in your first snippet. So you would have to do:

RoomStateController(int width, int height) : window(width, height) { ... }
- By Maverick Date 2009-06-08 19:36
I need to face palm myself. *face palmed*
Up Topic Gosu / Gosu Exchange / Gosu::Window and C++ member constructors

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill