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.


Messages - Kayy

Pages: [1]
1
DotNet / Re: Keyboard Input .net Style
« on: October 17, 2012, 08:15:18 pm »
Hello Laurent, and thank you for your reply.

Re-reading my post again, I see that I did a poor job of describing my issue. I'm not having a problem with the .Net binding of SFML but rather with weak overall programming skills. Coding I've done in the past didn't rely on events for keyboard input and I'm struggling with understanding how to use events properly; once I have a better grasp of that I'm confident that I will have no issues using the SFML for input.

I'll look through the example programs that come with the library for a demonstration, and hopefully it'll be easy to see where I've been going wrong.


[edit]

In the examples folder of the 2.0 download, all that I see are .exe files, and I don't know how to (or if I can) look at the code for those in a compiler. Is there another place where example code is stored so that I can look at it?

[re-edit]

Nevermind, I found the examples in GitHub, and they do clear up my confusion. And I forgot to say it previously, but thank you for your work on SFML Laurent, I've enjoyed using it so far.

2
DotNet / Keyboard Input .net Style
« on: October 17, 2012, 01:53:03 am »
I'm having some trouble dealing with input handling and SFML conceptually.

All of the documentation and references I can find describe a standard while loop that polls for events, but the .net bindings use DispatchEvents(). From what I can gather, this does all of the event polling internally to promote similarity with .net coding and design conventions.

But I'm not understanding how the approach is used in a c# SFML program. Does DispatchEvents() poll for any events on its own every time it's called in a loop? Can I register event handlers directly to them (i.e. OnKeyPress += new EventHandler(OnKeyPress)) to define how input will be processed?

I feel like this must be a pretty basic question, as it doesn't seem to have given anyone else on the internet any trouble. But I've not had any luck finding documentation for the .net binding, and experimenting to find out how it executes the functions documented for vanilla SFML sounds exhausting.

[edit]

I think my initial post was unclear. My program has a single RenderWindow which can display any one of multiple screens at a time.

My current plan is to set up an event handler in the main program (where the while loop that calls DispatchEvents() is), register the RenderWindow's KeyPressed event to it, and then execute the OnKeyPressed function each time the KeyPressed event fires. The OnKeyPressed function itself calls a function of the currently active screen (HandleInput) which takes the key code that fired the event as an argument. The active screen then parses the input on its own.

I'm pretty confident that this approach will work, but I'm not sure how "good" of an approach it is. Are there any aspects of SFML/c# that I'm missing or complicating by doing things this way?

Pages: [1]
anything