I'm trying to convert this
while (app.isOpen())
{
Event e;
while (app.pollEvent(e))
{
if (e.type == Event::Closed)
app.close();
}
From C++ to C#, However, When I'm trying to do the pollevent part I dont see such method, and this is basically the heart of the game I'm making, may someone please tell me what would be a proper way to translate this into C#
Look at this much simpler example (https://github.com/SFML/SFML.Net/blob/master/examples/window/Program.cs).
The relevant parts, with added comments:
// registers a handler for the KeyPressed event
window.KeyPressed += Window_KeyPressed;
// the event handler
private void Window_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
{
var window = (SFML.Window.Window)sender;
if (e.Code == SFML.Window.Keyboard.Key.Escape)
{
window.Close();
}
}
// this call checks events and triggers the registered handlers
window.DispatchEvents();
The rest (syntax, etc.) is pure C#, in case you're not familiar with delegates.