How would I make it so it knows what events to set up because I have different events depending on what screen I'm on?
your program is only one who knows what events is needed for you.
You can do it in the following way:
if (e
.Code == Keyboard
.Key.F11){ _isFullscreenChangeRequest
= true;}......public void Main
(){ CreateWindow
(); while (window
.IsOpen) { window
.DispatchMessages(); Update
(); Render
(window
); if (_isFullscreenChangeRequest
) { _isFullscreenChangeRequest
= false; _isFullscreen
= !_isFullscreen
; CreateWindow
(); } }}private void CreateWindow
(){ // first we need unsubscribe from all events window
.Resize -= Window_OnResize
; window
.KeyPressed -= Window_OnKeyPressed
; // then we need to dispose window window
.Dispose(); window
= null; // and now we can create new one window
= new new RenderWindow
( _isFullscreen
? new VideoMode
(PrimaryScreen
.X, PrimaryScreen
.Y) : new VideoMode
(1280,
720),
"RogueLike 2D " + context
.MajorVersion + "." + context
.MinorVersion,
_isFullscreen
? Styles
.Fullscreen : Styles
.Default,
context
); // and now you need to subscribe for events on a new window window
.Closed += (s,e
) => window
.Close(); window
.Resize += Window_OnResize
; window
.KeyPressed += Window_OnKeyPressed
; window
.SetVisible(true); window
.SetFrameLimit(0); window
.SetVerticalSyncEnabled(true);}
Unfortunately you cannot do all thins inside keypressed event due to the bug in SFML. (If you will try to dispose window from keypressed event it will leads to access violation error).
So, you need to notify the main loop about the change you need and then you can do all things safely from the main loop.
This sample is a little simplified and has some minor issues. Look for my topic here http://en.sfml-dev.org/forums/index.php?topic=19026.0
You will find good working example source code at the end of this topic.